PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » HTTP » HTTP_Request » Bug #1333

HTTP_Request always sets Content-Type on requests

Details

Submitted2004-05-03 19:45 UTC
Fromcardoe at cardoe dot com
Assignedavb
StatusClosed
PackageHTTP_Request
PHP VersionIrrelevant
OSLinux
Roadmaps(Not assigned)

Comments

[2004-05-03 19:45 UTC] cardoe at cardoe dot com

Description:
------------
HTTP_Request (version 1.2 & 1.2.1) always set Content-Type: application/x-www-form-urlencoded even on GET requests (this is the incorrect behavior.

As a follow up, if you do a POST request and reuse the same object to make a GET request, it will put the POST data in the content body. Also an incorrect behavior, it shouldn't put anything. Currently I'm using a ->clearPostData() method call, which is depreciated.

Reproduce code:
---------------
<?
$req->setURL("http://www.google.com");
$req->setMethod(HTTP_REQUEST_METHOD_GET);
$req->sendRequest();
//view this with Ethereal
//Content-Type is on

$req->setURL("http://www.google.com");
$req->setMethod(HTTP_REQUEST_METHOD_POST);
$req->addPostData("myVar", "1");
$req->sendRequest();

$req->setURL("http://www.google.com");
$req->setMethod(HTTP_REQUEST_METHOD_GET);
$req->sendRequest();
//view this with Ethereal
//my var will be sent like POST data and Content-Type is on.

Expected result:
----------------
no Content-Type for any GET & no previous POST data sent with GET.