PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTTP » HTTP_Request » Bug #4367

content-type is unexpectedly case-sensitive for POST requests

Details

Submitted2005-05-17 17:42 UTC
Fromgod at dailysedative dot com
Assignedavb
StatusClosed
PackageHTTP_Request
PHP Version4.3.8
OS*
Roadmaps(Not assigned)

Comments

[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);
}
}