[PEAR-BUG] Bug #20458 [Opn->Bgs]: HTTP_Request2 POST parameters ignored?
[email protected] Mon, 8 Dec 2014 10:59:34 +0000 (GMT)
| Newsgroups | php.pear.bugs |
|---|---|
| Message-ID | <[email protected]> |
Edit report at https://pear.php.net/bugs/bug.php?id=20458&edit=1 ID: 20458 Updated by: [email protected] Reported By: lennart dot borgman at gmail dot com Summary: HTTP_Request2 POST parameters ignored? -Status: Open +Status: Bogus Type: Bug Package: HTTP_Request2 Operating System: Cygwin Package Version: 2.2.1 PHP Version: 5.5.19 Roadmap Versions: New Comment: -Status: Open +Status: Bogus This is not a bug, thus my answer goes to stackoverflow Previous Comments: ------------------------------------------------------------------------ [2014-12-07 16:13:52] lborgman Description: ------------ I am not sure if this is a bug since I am not totally sure about the syntax/semantics for POST. However when I compare with the result from a call to curl the results differ. And it looks like the parameters to POST have been ignored (like they were null). The test script below is run against an OpenSearchServer (see http://opensearchserver.com, essentially Lucene, i.e. java). The corresponding curl call looks like this: curl -XPOST -H "Content-Type: application/json" -d '{"query":"porges","start":0,"rows":10,"lang":"ENGLISH"}' http://localhost:8080/services/rest/index/z56508/search/field/search I have tried to ask a question about this here: http://stackoverflow.com/questions/27340190/http-request2-post- parameters-ignored Test script: --------------- <?php require_once 'HTTP/Request2.php'; $url = "http://localhost:8080/services/rest/index/z56508/search/field/search"; $data = array("query"=>"porges","start"=>"0","rows"=>"10","lang"=>"ENGLISH"); // $data = null; $r = new HTTP_Request2($url); $r->setHeader('Content-Type', 'application/json;charset=UTF-8'); $r->setMethod(HTTP_Request2::METHOD_POST) ->addPostParameter($data); $response = $r->send(); $responseStatus = $response->getStatus(); if ($responseStatus < 200 || $responseStatus >= 400) { echo "\n\n" . $queryUrl . "\n\n"; echo "Bad status: " . $responseStatus; echo " " . $response->getReasonPhrase(); echo "\n" . $response->getBody(); exit; } $body = $response->getBody(); echo $body; Expected result: ---------------- I expected 11 hits. Actual result: -------------- I got 2445 hits (which is all records in the OpenSearchServer database). ------------------------------------------------------------------------ -- Edit this bug report at https://pear.php.net/bugs/bug.php?id=20458&edit=1