使用方法POST发送时使用ZF3 Http Client的方法GET进行发送

时间:2019-07-04 12:05:42

标签: httpclient zend-framework3

我正在尝试使用ZF3 Http Client发出POST请求,但它一直都是GET请求。我在zend Framework网站上检查了手册,但找不到我做错的事情。可能会很小。

我在客户端的简单脚本是:

$request = new Client();

        $request->setUri('http://keuringapp.localhost/inspections/pdf/66');
        $request->setMethod(Request::METHOD_POST);

        $response = $request->send();
        die($response->getBody());

在服务器端,我有这个:

$test = $this->getRequest();
        print_r($test);exit();
``

and it give met this result:

Zend\Http\PhpEnvironment\Request Object
(
    [baseUrl:protected] => 
    [basePath:protected] => 
    [requestUri:protected] => /nl/inspections/pdf/66
    [serverParams:protected] => Zend\Stdlib\Parameters Object
        (
            [storage:ArrayObject:private] => Array
                (
                    [REDIRECT_APP_ENV] => development
                    [REDIRECT_STATUS] => 200
                    [APP_ENV] => development
                    [HTTP_HOST] => keuringapp.localhost
                    [HTTP_CONNECTION] => close
                    [HTTP_ACCEPT_ENCODING] => gzip, deflate
                    [HTTP_USER_AGENT] => Zend\Http\Client
                    [PATH] => /usr/bin:/bin:/usr/sbin:/sbin
                    [SERVER_SIGNATURE] => 
                    [SERVER_SOFTWARE] => Apache
                    [SERVER_NAME] => keuringapp.localhost
                    [SERVER_ADDR] => ::1
                    [SERVER_PORT] => 80
                    [REMOTE_ADDR] => ::1
                    [DOCUMENT_ROOT] => /Applications/MAMP/htdocs/keuringapp/public
                    [SERVER_ADMIN] => you@example.com
                    [SCRIPT_FILENAME] => /Applications/MAMP/htdocs/keuringapp/public/index.php
                    [REMOTE_PORT] => 55447
                    [REDIRECT_URL] => /nl/inspections/pdf/66
                    [GATEWAY_INTERFACE] => CGI/1.1
                    [SERVER_PROTOCOL] => HTTP/1.1
                    [REQUEST_METHOD] => GET
                    [QUERY_STRING] => 
                    [REQUEST_URI] => /nl/inspections/pdf/66
                    [SCRIPT_NAME] => /index.php
                    [PHP_SELF] => /index.php
                    [REQUEST_TIME_FLOAT] => 1562241261.33
                    [REQUEST_TIME] => 1562241261
                    [argv] => Array
                        (
                        )

                    [argc] => 0
                )

        )

1 个答案:

答案 0 :(得分:-1)

可以关闭此问题。这是由于网址中的语言设置引起的问题