Further to this... Basically, the way the code below works is to provide an Reader to the InputStream created by the URL object's method getContent(). This can be read line by line using readline(). Because the URL object doesn't pull all the data into it immediately, but provides a way of accessing the stream, it is this that you would need to check, so the code below is updated (and not perfect by any means) and provides a test implementation of a timeout.
I'm not sure if it works exactly right, but it does chuck an error if it times out before the code is finished (ie in the loop). The timeout would not be checked if there was no content however (although I think this may throw an error, but I can't be sure)... HTH ----code---- <cfparam name="url.link" default="http://google.com"> <cfset starttime = gettickcount()> <cfscript> objURL = createobject("Java", "java.net.URL"); myURL = objURL.init(url.link); objisr = createobject("Java", "java.io.InputStreamReader"); objBr = createObject("Java", "java.io.BufferedReader"); isr = objisr.init(myURL.getContent()); br = objbr.init(isr); </cfscript> <cfset line = br.readline()> <cfset content = ""> <cfset a = 1> <cfloop condition="#IsDefined("line")#"> <cfif len(content) gt 0> <cfset content = content & chr(10) & chr(13) & line> <cfelse> <cfset content = line> </cfif> <cfset diff = gettickcount() - starttime> <cfif diff gt 10000> <cfthrow type="TIMEOUT"> </cfif> <cfset a = a+1> <cfset line = br.readline()> </cfloop> <cfoutput>#content#</cfoutput> ----code---- Paul > -----Original Message----- > From: Alex Skinner [mailto:[EMAIL PROTECTED] > Sent: 30 July 2003 16:43 > To: [EMAIL PROTECTED] > Subject: RE: [ cf-dev ] CFHTTP > > > Cool, thanks how do you specify a timeout though ? > > Alex > > -----Original Message----- > From: Paul Johnston [mailto:[EMAIL PROTECTED] > Sent: 30 July 2003 15:27 > To: [EMAIL PROTECTED] > Subject: RE: [ cf-dev ] CFHTTP > > > Alex... > > Knocked this up... HTH > > ----code---- > <cfscript> > objURL = createobject("Java", "java.net.URL"); > myURL = objURL.init("http://www.google.com"); > objisr = createobject("Java", "java.io.InputStreamReader"); > objBr = createObject("Java", "java.io.BufferedReader"); > isr = objisr.init(myURL.getContent()); > br = objbr.init(isr); > </cfscript> > > <cfset line = br.readline()> > <cfloop condition="#IsDefined("line")#"> > <cfoutput>#htmleditformat(line)#</cfoutput> > <cfset line = br.readline()> > </cfloop> > ----code---- > > Just wrap the last bit in a <cfsavecontent> and you'll have > pretty much what you need! > > Paul > > > -----Original Message----- > > From: Alex Skinner [mailto:[EMAIL PROTECTED] > > Sent: 30 July 2003 15:35 > > To: [EMAIL PROTECTED] > > Subject: [ cf-dev ] CFHTTP > > > > > > Guys, > > > > As you may know there is a bug with CFHTTP that effects MX > in that the > > timeout attribute is ignored which means cfhttp waits until the > > request times out if the resource isnt available. > > > > This is meant to be fixed in the upcoming updater but has > anyone got > > any code for doing a standard cfhttp get using straight java code ? > > > > Alex > > > > > > > > -- > > ** Archive: > http://www.mail-archive.com/dev%> 40lists.cfdeveloper.co.uk/ > > > > > To unsubscribe, e-mail: > [EMAIL PROTECTED] > > For additional commands, e-mail: > [EMAIL PROTECTED] For > > human help, e-mail: [EMAIL PROTECTED] > > > > > > -- > ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ > > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] For human help, e-mail: > [EMAIL PROTECTED] > > > > > -- > ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ > > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: > [EMAIL PROTECTED] For human help, e-mail: > [EMAIL PROTECTED] > -- ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] For human help, e-mail: [EMAIL PROTECTED]
