WordPress.org

Make WordPress Core

Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#7770 closed defect (bug) (fixed)

HTTP API: Chunked fails, Redirects fail, and warnings

Reported by: DD32 Owned by:
Milestone: 2.7 Priority: normal
Severity: normal Version: 2.7
Component: General Keywords: has-patch
Focuses: Cc:

Description

It appears that not all hosts which set the transfer-encoding to chunked, actually send the output in chunked format.

An example site of this is http://www.spiritblog.net/ (Purely random selection)

The issue is that WP_Http::chunkTransferDecode() will return false on this event.

I see 2 solutions:

  • Have chunkTransferDecode() return the content back if its deterined not to be chunked
  • have the transports check that the return result of chunkTransferDecode() is true before assigning to the body.

Option 1 seems a good route honestly, Decode it if its determined to be chunked, else just pass it back. Patch will be attached for this route shortly.

Attachments (3)

7770.diff (828 bytes) - added by DD32 12 years ago.
7770.2.diff (5.7 KB) - added by DD32 12 years ago.
7770.3.diff (4.4 KB) - added by DD32 12 years ago.
extra redirect code wasnt needed.

Download all attachments as: .zip

Change History (11)

@DD32
12 years ago

#1 follow-up: @DD32
12 years ago

A Thought just occured to me, Its using the CURL transport on that server, Could it be that the Server might be returning chunked format, But the curl library is decoding it instead?

#2 @DD32
12 years ago

Also related;

The HTTP Extension chunked decode may fail with an error if the timeout occured before the request fully finished:

Warning: http_request() [function.http-request]: a timeout was reached; Operation timed out after 5 seconds with 32097 bytes received (http://whosit.wamble.net/) in /test/wp-includes/http.php on line 861

( ! ) Warning: http_chunked_decode() [function.http-chunked-decode]: Truncated message: chunk size 71343 exceeds remaining data size 32097 at pos 7 of 32104 in //test/wp-includes/http.php on line 873

#3 in reply to: ↑ 1 @jacobsantos
12 years ago

Replying to DD32:

A Thought just occured to me, Its using the CURL transport on that server, Could it be that the Server might be returning chunked format, But the curl library is decoding it instead?

I've noticed that also, however I kept it there in case I was incorrect.

#4 @Otto42
12 years ago

Yes, this is definitely a curl thing. If curl receives a chunked message, then it passes back a single non-chunked response to PHP, but it also leaves the Transfer-Encoding: chunked header.

Probably should make the curl module always assume the message is not chunked, since curl deals with it for you.

#5 @jacobsantos
12 years ago

So the solutions are remove the chunked decode from cURL and well, there is not yet a good solution for the warnings.

#6 @DD32
12 years ago

  • Summary changed from HTTP API: Chunked transfer decode fails. to HTTP API: Chunked fails, Redirects fail, and warnings

Changed the title of this ticket to reflect the contents of the latest patch

  • General: Move body processing functions after redirect checks
  • Curl: Remove chunked transfer check
  • Curl: When it redirects, it returns the headers for each request, use the last set of headers from the list
  • Fopen / Streams: Implement redirects
  • Ext HTTP: Handle error conditions, silence warnings

@DD32
12 years ago

@DD32
12 years ago

extra redirect code wasnt needed.

#7 @jacobsantos
12 years ago

7770.3.diff looks good to me.

#8 @ryan
12 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [9091]) Chunked encoding fixes from DD32. fixes #7770

Note: See TracTickets for help on using tickets.