Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.4

Bug #4367 content-type is unexpectedly case-sensitive for POST requests
Submitted: 2005-05-17 17:42 UTC
From: god at dailysedative dot com Assigned: avb
Status: Closed Package: HTTP_Request
PHP Version: 4.3.8 OS: *
Roadmaps: (Not assigned)    
Subscription  


 [2005-05-17 17:42 UTC] god at dailysedative dot com
Description: ------------ For post reqeusts, this fails to work as the request defaults back to "application/x-www-form-urlencoded" encoding without warning: $req->addHeader('Content-type','multipart/form-data'); This works as expected: $req->addHeader('Content-Type','multipart/form-data'); So it won't encode the post the way you expect unless you Upper-Case Content-Type. I've included a low-level fix below. Reproduce code: --------------- --- /usr/share/pear/HTTP/Request.php 2005-02-17 12:20:08.000000000 -0500 +++ Request.php 2005-05-17 13:40:32.000000000 -0400 @@ -729,12 +729,15 @@ if (HTTP_REQUEST_METHOD_POST != $this->_method && HTTP_REQUEST_METHOD_PUT != $this->_method) { $this->removeHeader('Content-Type'); + $this->removeHeader('Content-type'); } else { - if (empty($this->_requestHeaders['Content-Type'])) { + if (empty($this->_requestHeaders['Content-Type']) && empty($this->_requestHeaders['Content-type'])) { // Add default content-type $this->addHeader('Content-Type', 'application/x-www-form-urlencoded'); - } elseif ('multipart/form-data' == $this->_requestHeaders['Content-Type']) { + } elseif ('multipart/form-data' == $this->_requestHeaders['Content-Type'] || 'multipart/form-data' == $this->_requestHeaders['Content-type']) { $boundary = 'HTTP_Request_' . md5(uniqid('request') . microtime()); + $this->removeHeader('Content-Type'); + $this->removeHeader('Content-type'); $this->addHeader('Content-Type', 'multipart/form-data; boundary=' . $boundary); } }

Comments

 [2005-11-05 19:21 UTC] avb
Fixed in CVS. All header names are now treated case-insensitively, per RFC 2616.