cURL / Mailing Lists / curl-library / Single Mail


401 response bodies carried over

From: Troy Davisson <>
Date: Thu, 6 Nov 2008 14:34:09 -0500

I'm seeing some strange behavior in a few test cases where, using the
request settings below, the HTTP body of the HTTP 401 response is
being added to the HTTP body of the HTTP 200 response following
successful authentication.

$this->ch = curl_init();
curl_setopt($this->ch, CURLOPT_HEADERFUNCTION, array(&$this,
curl_setopt($this->ch, CURLOPT_HEADER, false);
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($this->ch, CURLOPT_USERPWD, $this->username.":".$this->password);
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($this->ch, CURLOPT_COOKIEFILE, $this->cookie_file);
curl_setopt($this->ch, CURLOPT_COOKIEJAR, $this->cookie_file);
curl_setopt($this->ch, CURLOPT_URL, $request_url);
curl_setopt($this->ch, CURLOPT_HTTPHEADER, array($request_headers));
$response_body = curl_exec($this->ch);

I've looked through the setopt options and I've looked over the curl
changelog and don't see anything that sticks out as the offender. The
relevant $response_body's in my case are in XML so having XML
(containing a text error from the 401 response) and XML (containing
the success message from the 200 response) coming back as the single
body is causing some problems.

The only consistency I think I've seen so far has been a slight
difference in curl versions but I haven't been able to narrow it down

Is this a known behavior or is there a curl option I'm missing? Has
anyone else run into this before?

Thanks in advance!

- Troy
Received on 2008-11-06