cURL / Mailing Lists / curl-and-php / Single Mail

curl-and-php

Does cURL resend request prior to returning, 52 error?

From: Laurie Barker <laurie_at_oneuponedown.co.uk>
Date: Mon, 04 Aug 2003 19:36:11 +0100

Hello

Can anybody advise as to weather cURL retries a HTTP1.1 POST when it
encounters a 52 error (The server didn't reply anything), or is it up to us
to program this functionality?

Background Info:
cURL version: 7.10.4

We are 100% positive that the fault with regard the encountered error 52 is
not due to cURL. In this case cURL is used as a fall back routine in our
screen scrape class, in the event the fsockopen HTTP1.0 request returns
empty and only when failure is not due to connect/timeout error.

cURL was wrote into the class to solve this issue and in part it has,
changing the error from 100% consistent failure when performing a POST with
HTTP1.0, to intermittent failure when performing a POST with HTTP1.1.

This error is only encountered when communicating with a particular
site/server, we are convinced that the server (IBM-HTTP-Server/1.0) is
prematurely closing the connection.

My question is based on my interpretation of the following:

Extract from http://www.ietf.org/rfc/rfc2616.txt, Hypertext Transfer
Protocol -- HTTP/1.1 standard document (gripping bedtime reading).

8.2.4 Client Behavior if Server Prematurely Closes Connection

   If an HTTP/1.1 client sends a request which includes a request body,
   but which does not include an Expect request-header field with the
   "100-continue" expectation, and if the client is not directly
   connected to an HTTP/1.1 origin server, and if the client sees the
   connection close before receiving any status from the server, the
   client SHOULD retry the request. If the client does retry this
   request, it MAY use the following "binary exponential backoff"
   algorithm to be assured of obtaining a reliable response:

      1. Initiate a new connection to the server

      2. Transmit the request-headers

      3. Initialize a variable R to the estimated round-trip time to the
         server (e.g., based on the time it took to establish the
         connection), or to a constant value of 5 seconds if the round-
         trip time is not available.

      4. Compute T = R * (2**N), where N is the number of previous
         retries of this request.

      5. Wait either for an error response from the server, or for T
         seconds (whichever comes first)

      6. If no error response is received, after T seconds transmit the
         body of the request.

      7. If client sees that the connection is closed prematurely,
         repeat from step 1 until the request is accepted, an error
         response is received, or the user becomes impatient and
         terminates the retry process.

   If at any point an error status is received, the client

      - SHOULD NOT continue and

      - SHOULD close the connection if it has not completed sending the
        request message.

-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
Received on 2003-08-04