在进行反对服务时,http连接不会关闭

时间:2013-08-14 21:09:36

标签: http connection http-get

当我使用以下对此URL进行HTTP GET时:

curl -HAccept:text/plain -v http://my-ip-address/myservice

我得到以下输出:

* About to connect() to my-ip-address port 80 (#0)
*   Trying my-ip-address...
* connected
* Connected to my-ip-address (my-ip-address) port 80 (#0)
> GET /myservice HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8x zlib/1.2.5
> Host: my-ip-address
> Accept:text/plain
> 
< HTTP/1.1 200 OK
< Date: Wed, 14 Aug 2013 16:01:29 GMT
< Server: Apache/2.2.25 (Amazon)
< Connection: close
< Transfer-Encoding: chunked
< Content-Type: text/plain; charset=UTF-8
< 
My Output

* Closing connection #0

当我使用域尝试以下操作时,连接保持活动状态并且不允许我的程序执行后续获取:

curl -HAccept:text/plain -v http://my-domain.com/myservice


* About to connect() to my-domain port 80 (#0)
*   Trying my-ip...
* connected
* Connected to  (my-ip) port 80 (#0)
> GET /myservice/ HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8x zlib/1.2.5
> Host: my-domain
> Accept:text/plain
> 
< HTTP/1.1 503 Service Unavailable: Back-end server is at capacity
< Content-Length: 0
< Connection: keep-alive
< 
* Connection #0 to host my-domain left intact
* Closing connection #0

1 个答案:

答案 0 :(得分:0)

http 1.1在默认情况下不会关闭,但会保持开放以提高速度。