• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

cfhttp and timeout

New Here ,
Jul 20, 2006 Jul 20, 2006

Copy link to clipboard

Copied

I'm using cfhttp with a timeout value, but how do I know if I timed out?

Can't seem to find any examples online or at the macromedia livedocs. Perhaps, it returns a statuscode 408. How can I test this sort of thing?
TOPICS
Advanced techniques

Views

3.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 20, 2006 Jul 20, 2006

Copy link to clipboard

Copied

If the cfhttp call times out it throws an ColdFusion Exception (Unless
the don't throw exception option is selected IIRC). You would handle
this with any of the ColdFusion Exception handling features.

<cftry...><cfcatch...>

And|Or

<cferror>

And|Or

The Administrator Error settings

To name a couple.

leesiulung2006 wrote:
> I'm using cfhttp with a timeout value, but how do I know if I timed out?
>
> Can't seem to find any examples online or at the macromedia livedocs. Perhaps,
> it returns a statuscode 408. How can I test this sort of thing?
>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 20, 2006 Jul 20, 2006

Copy link to clipboard

Copied

<CFOUTPUT>#CFHTTP.FileContent#</CFOUTPUT> will show you the 408 error. Go to http://livedocs.macromedia.com/coldfusion/5.0/CFML_Reference/Tags47.htm#1632966 for more information.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 20, 2006 Jul 20, 2006

Copy link to clipboard

Copied

jdeline,

I am aware of the filecontent and the return value of cfhttp. However, can I assume that after the "call" to cfhttp tags the cfhttp.Responseheader.Status_Code will always be filled out afterwards? Is this how I get notified of a 408 Timeout?

Seems like the documentation although available seems to be missing detailed information about how to handle things or it is me who is not as familiar with how html pages with headers etc... are handled.

thanks jdeline!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 20, 2006 Jul 20, 2006

Copy link to clipboard

Copied

There are two states involved here. If the remote server returns an
HTTP error, even a timeout one, that is NOT a <cfhttp> timeout error.
<cfhttp> go a response, the http error message and that response will be
placed into the <cfhttp> response structure. So yes, you can count on
the status_code being any status_code the remote server returned, and
the filecontent to be any file content returned.

The <cfhttp...> timeout parameter is how long the process will wait for
any response from the remote server. If no response, http error or
otherwise, is received within the specified time limit cfhttp will throw
a ColdFusion exception that you handle with ColdFusion exception
handling functions.

So you have two questions to ask when working with <cfhttp...>. Did I
get a response? And if so, what was that response?

leesiulung2006 wrote:
> jdeline,
>
> I am aware of the filecontent and the return value of cfhttp. However, can I
> assume that after the "call" to cfhttp tags the
> cfhttp.Responseheader.Status_Code will always be filled out afterwards? Is this
> how I get notified of a 408 Timeout?
>
> Seems like the documentation although available seems to be missing detailed
> information about how to handle things or it is me who is not as familiar with
> how html pages with headers etc... are handled.
>
> thanks jdeline!
>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 20, 2006 Jul 20, 2006

Copy link to clipboard

Copied

Ian,

For some reason your post did not show up the previous time I viewed it although you posted before jdeline... wierd.

Anyhow, I turned off throwonerror, but for the future. How do I know that this particular timeout error occured and not something else if I use cftry/catch. The error type that "catch" catches is not clear (there are only like 10 different kinds).

In programming languages like java there are exceptions with a type (class) that indicates what happened in a try/catch clause.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 20, 2006 Jul 20, 2006

Copy link to clipboard

Copied

duplicate post,

is it me or adobe web site soooo slow....

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 20, 2006 Jul 20, 2006

Copy link to clipboard

Copied

LATEST
When you use <cfcatch> ColdFusion builds an exception structure named
"cfcatch". This will include the exception type and other data. You
can start by <cfdump var="#cfcatch#"> and it will show all the data
about the exception.

You can also type your <cfcatch type="database"...> blocks. This allows
you to build different exception handling code for different potential
exceptions.

And remember, with <cfhttp...> Receiving a http error is NOT an
exception. As far as <cfhttp> is concerned a result was returned. It
is up to you to examine that result and determine if it is an expected
result or not. You would use the #cfhttp# structure (or other named
structure if using MX7+) to examine the result.

You can use the <cfthrow...> tag if you would like to throw a custom
exception to your try/catch logic based on the result returned by <cfhttp>

HTH


leesiulung2006 wrote:
> Ian,
>
> For some reason your post did not show up the previous time I viewed it
> although you posted before jdeline... wierd.
>
> Anyhow, I turned off throwonerror, but for the future. How do I know that this
> particular timeout error occured and not something else if I use cftry/catch.
> The error type that "catch" catches is not clear (there are only like 10
> different kinds).
>
> In programming languages like java there are exceptions with a type (class)
> that indicates what happened in a try/catch clause.
>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation