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

Bug #1333 HTTP_Request always sets Content-Type on requests
Submitted: 2004-05-03 19:45 UTC
From: cardoe at cardoe dot com Assigned: avb
Status: Closed Package: HTTP_Request
PHP Version: Irrelevant OS: Linux
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 31 + 38 = ?

 
 [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.

Comments

 [2004-05-08 19:14 UTC] avb
I've looked through HTTP spec and couldn't find any passage that prohibited adding Content-Type to the request with no body. If you know such a passage, please point to it. Sending post data in GET request is obviously a bug and will be fixed. clearPostData() and friends are deprecated for the reason that HTTP_Request was not really designed to perform multiple requests, thus a better approach is to create a new instance of it rather than reuse an old one.
 [2004-05-19 10:58 UTC] avb
Thanks, fixed in release 1.2.2