Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#17731 closed defect (bug) (worksforme)

Curl HTTP request via proxy contain error

Reported by: hpatoio's profile hpatoio Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.0.4
Component: HTTP API Keywords: reporter-feedback
Focuses: Cc:


Hello, I've just faced a problem while I was doing curl request via proxy(squid)

Basically the response with proxy is

HTTP/1.0 200 Connection established

HTTP/1.1 200 OK
Date: Sun, 22 Feb 2009 09:30:52 GMT
Server: Apache/2.2.8
X-Powered-By: PHP/5.3.1

without is

HTTP/1.1 200 OK
Date: Sun, 22 Feb 2009 09:30:52 GMT
Server: Apache/2.2.8
X-Powered-By: PHP/5.3.1

This cause a problem during the response parsing because the value returned by curl_getinfo($handle, CURLINFO_HEADER_SIZE) doesn't take in account "HTTP/1.0 200 Connection established"

The following lines of code solve the problem

if ( ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) && (stripos($theResponse, "HTTP/1.0 200 Connection established\r\n\r\n") !== false) ) {
	            $theResponse = str_ireplace("HTTP/1.0 200 Connection established\r\n\r\n", '', $theResponse);

Am I the only one with this problem ? I've searched and it doesn't look like a curl bug.

Change History (4)

#1 @dd32
13 years ago

just to confirm, You're using 3.0.4? Have you tried 3.1 or 3.2 beta releases in that environment?

3.2 has changed some code in relation to curl header parsing, so If you can test a beta of 3.2, that'd be greatly appreciated.

#2 @dd32
13 years ago

  • Keywords reporter-feedback added

3.2 appears to work correctly for me.

We no longer use CURLINFO_HEADER_SIZE at all, so any potential string functions which were previously failing are no longer a problem.

hpatoio: You may wish to try using a copy of Trunk's class-http.php as it should be compatible with 3.1, see if that solves the problem for you if you're not up for using a 3.2 beta.

#3 @hpatoio
13 years ago

Hello, unfortunately at the moment in my test environment I don't have a proxy so I can't check the 3.2 version (neither the single file)

In the next days I'll add a proxy to my test environment and I'll give you feedbacks.

Thanks for your work & time !

#4 @SergeyBiryukov
13 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Feel free to reopen with more information if there's still a problem.

Note: See TracTickets for help on using tickets.