We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
测试代码:
<?php require('vendor/autoload.php'); go(function() { $saber = Swlib\Saber::create([ 'base_uri' => 'http://127.0.0.1', 'headers' => [ 'Host' => 'example.com', 'X-Test' => 'test' ] ]); echo $saber->get('/host.php'); echo "\n-------------------\n"; $saber = Swlib\Saber::create([ 'base_uri' => 'http://127.0.0.1' ]); $saber->setOptions([ 'headers' => [ 'Host' => 'example.com', 'X-Test' => 'test' ] ]); echo $saber->get('/host.php'); });
服务器输出内容是:(打印了$_SERVER):
HTTP/1.1 200 OK Server: nginx Date: Wed, 03 Oct 2018 02:57:14 GMT Content-Type: text/html; charset=UTF-8 Transfer-Encoding: chunked Connection: keep-alive Vary: Accept-Encoding Content-Encoding: gzip Array ( [TEMP] => /tmp [TMPDIR] => /tmp [TMP] => /tmp [PATH] => /usr/local/bin:/usr/bin:/bin [USER] => www [HOME] => /home/www [HTTP_X_TEST] => test [HTTP_CONTENT_TYPE] => application/x-www-form-urlencoded [HTTP_USER_AGENT] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36 [HTTP_ACCEPT_ENCODING] => gzip [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 [HTTP_HOST] => 127.0.0.1 [HTTP_CONNECTION] => keep-alive [REDIRECT_STATUS] => 200 [SERVER_NAME] => _ [SERVER_PORT] => 80 [SERVER_ADDR] => 127.0.0.1 [REMOTE_PORT] => 46126 [REMOTE_ADDR] => 127.0.0.1 [SERVER_SOFTWARE] => nginx/1.12.2 [GATEWAY_INTERFACE] => CGI/1.1 [REQUEST_SCHEME] => http [SERVER_PROTOCOL] => HTTP/1.1 [DOCUMENT_ROOT] => /web/wwwroot/default [DOCUMENT_URI] => /host.php [REQUEST_URI] => /host.php [SCRIPT_NAME] => /host.php [CONTENT_LENGTH] => [CONTENT_TYPE] => application/x-www-form-urlencoded [REQUEST_METHOD] => GET [QUERY_STRING] => [SCRIPT_FILENAME] => /web/wwwroot/default/host.php [FCGI_ROLE] => RESPONDER [PHP_SELF] => /host.php [REQUEST_TIME_FLOAT] => 1538535434.4496 [REQUEST_TIME] => 1538535434 ) ------------------- HTTP/1.1 200 OK Server: nginx Date: Wed, 03 Oct 2018 02:57:14 GMT Content-Type: text/html; charset=UTF-8 Transfer-Encoding: chunked Connection: keep-alive Vary: Accept-Encoding Content-Encoding: gzip Array ( [TEMP] => /tmp [TMPDIR] => /tmp [TMP] => /tmp [PATH] => /usr/local/bin:/usr/bin:/bin [USER] => www [HOME] => /home/www [HTTP_X_TEST] => test [HTTP_CONTENT_TYPE] => application/x-www-form-urlencoded [HTTP_USER_AGENT] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36 [HTTP_ACCEPT_ENCODING] => gzip [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8 [HTTP_HOST] => 127.0.0.1 [HTTP_CONNECTION] => keep-alive [REDIRECT_STATUS] => 200 [SERVER_NAME] => _ [SERVER_PORT] => 80 [SERVER_ADDR] => 127.0.0.1 [REMOTE_PORT] => 46128 [REMOTE_ADDR] => 127.0.0.1 [SERVER_SOFTWARE] => nginx/1.12.2 [GATEWAY_INTERFACE] => CGI/1.1 [REQUEST_SCHEME] => http [SERVER_PROTOCOL] => HTTP/1.1 [DOCUMENT_ROOT] => /web/wwwroot/default [DOCUMENT_URI] => /host.php [REQUEST_URI] => /host.php [SCRIPT_NAME] => /host.php [CONTENT_LENGTH] => [CONTENT_TYPE] => application/x-www-form-urlencoded [REQUEST_METHOD] => GET [QUERY_STRING] => [SCRIPT_FILENAME] => /web/wwwroot/default/host.php [FCGI_ROLE] => RESPONDER [PHP_SELF] => /host.php [REQUEST_TIME_FLOAT] => 1538535434.4521 [REQUEST_TIME] => 1538535434 )
可以看到,X-Test头是成功了的,Host头修改无效
The text was updated successfully, but these errors were encountered:
dbe817f
设计失误, 被URI对象中的Host覆盖了两次, 一般场景都是直接填host的, 所以没有发现.
Sorry, something went wrong.
No branches or pull requests
测试代码:
服务器输出内容是:(打印了$_SERVER):
可以看到,X-Test头是成功了的,Host头修改无效
The text was updated successfully, but these errors were encountered: