#16885 closed defect (bug) (fixed)
Warning emited in Header parsing when server does not specify a response "Message"
Reported by: | dd32 | Owned by: | dd32 |
---|---|---|---|
Milestone: | 3.2 | Priority: | normal |
Severity: | normal | Version: | 3.1 |
Component: | HTTP API | Keywords: | has-patch |
Focuses: | Cc: |
Description (last modified by )
As reported in #16855 by cogmios, the HTTP API class can emit a warning in the case that a server does not specify the response message.
One example of a URL which causes this is: http://wallpapers.protonet.ru/section/foto/O/ which has a response of:
HTTP/1.1 404 Server: nginx/0.6.32
causing:
Undefined offset: 2 in \wp-includes\class-http.php on line <i>442</i>
Code in question: list( , $response['code', $responsemessage?) = explode(' ', $tempheader, 3);]
One potential patch would be:
$p = explode(' ', $tempheader, 3); array_shift($p); $response['code'] = array_shift($p); $response['message'] = array_shift($p);
Attachments (2)
Change History (18)
#4
@
14 years ago
As that is a HTTP/1.1 response, the server is violating the HTTP specification.
The Reason-Phrase of the Status-Line in HTTP Resonse Messages is not optional. However our HTTP client is not required to examine or display the Reason-Phrase so I think it's okay to deal with a missing SP and phrase.
I think it's worth to report that problem with the NGINX project.
See 6.1 Status-Line (http 1.1, for http 1.0)
#6
@
14 years ago
Default Response Phrase is Empty. The RFC offers some default Phrases, but IMHO that would be a bit much to provide for a buggy HTTP server resonse.
#9
@
14 years ago
the patch as proposed does not solve the issue since then you would get;
"Notice: Undefined offset: 1 i" etc... instead
How did you get that? array_shift() will return null on an empty array/non-array.
#10
@
14 years ago
"Notice: Undefined offset: 1 in C:\xampp\htdocs\wp2\wp-includes\class-http.php on line 457"....
I assumed it was the changed code..... but was this line after it..... :
list($key, $value) = explode(':', $tempheader, 2);
because i dropped the continue, sry
if ( false === strpos($tempheader, ':') ) { $p = explode(' ', $tempheader, 3); array_shift($p); $response['code'] = array_shift($p); $response['message'] = array_shift($p); continue; }
#12
@
14 years ago
- Component changed from Warnings/Notices to HTTP
- Type changed from enhancement to defect (bug)
#13
follow-up:
↓ 14
@
14 years ago
- Cc azizur added
Not sure if this related and if it could be address at the time.
When the fetching a url for rss which is unreachable you also get:
Warning: Invalid argument supplied for foreach() in {path-to}/wp-includes/class-http.php on line 362 RSS Error: A feed could not be found at http://my-disfunctional-url.org/news/feed/
This is not helpful to average users/subscribers when they see this once they are re-directed to dashboard after login.
Want to re-produce it?
Go to Dashboard and change the "WordPress Blog" or "Dashboard Primary" widget url to something that does not work.
#14
in reply to:
↑ 13
@
14 years ago
Replying to azizur:
Which transport is that? I get RSS Error: WP HTTP Error: Could not open handle for fopen() to http://my-disfunctional-url.org/news/feed/ on current trunk. Probably because of the transport or the recent changes.
#16
@
14 years ago
- Milestone changed from Awaiting Review to 3.2
went with the empty message field since that's what the server is returning.
The message can be absolutely anything "HTTP/1.1 200 Woot!" is a completely valid response, although discouraged. Any code should be validating based on the response code, so an empty message is not the end of the world.
the patch as proposed does not solve the issue since then you would get;
"Notice: Undefined offset: 1 i" etc... instead
ALSO: The code i put in the other ticket with first checking the count is not the complete answer since that also give the notice on "1"