Why cURL response from server is HTTP/1.0?

Dmitry Petukhov

I had created simple server in terminal

python -m SimpleHTTPServer 8000

when I send command curl -I http://localhost:8000

and command result was a request:

127.0.0.1 - - [07/Aug/2016 14:53:22] "GET / HTTP/1.1" 200 -

but response was a HTTP/1.0

HTTP/1.0 200 OK
Server: SimpleHTTP/0.6 Python/2.7.12
Date: Sun, 07 Aug 2016 10:02:08 GMT
Content-type: text/html; charset=utf-8
Content-Length: 9747

curl -v http://localhost:8000

* Rebuilt URL to: http://localhost:8000/
*   Trying ::1...
* connect to ::1 port 8000 failed: Connection refused
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8000 (#0)
> GET / HTTP/1.1
> Host: localhost:8000
> User-Agent: curl/7.43.0
> Accept: */*
>
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: SimpleHTTP/0.6 Python/2.7.12
< Date: Sun, 07 Aug 2016 10:02:23 GMT
< Content-type: text/html; charset=utf-8
< Content-Length: 9747
<
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html>
...
</html>
* Closing connection 0

How we can explain this? Why server response was not a HTTP/1.1

cuongnv23

curl uses HTTP/1.1 by default from version 7.33.0 (yours is 7.43.0). In man curl:

--http1.1
              (HTTP) Tells curl to use HTTP version 1.1. This is the internal default version. (Added in 7.33.0)

So curl will make a request with HTTP/1.1 to your server.

This line 127.0.0.1 - - [07/Aug/2016 14:53:22] "GET / HTTP/1.1" 200 -

is just a log entry which tells you that there is a request made with expected to get HTTP/1.1 BUT it doesn't mean server must response with HTTP/1.1, see the link of Karoly Horvath for detail.

Looking at source code of SimpleHTTPServer, you can see there is a default request version which is HTTP/0.9.

This default_request_version variable is then assigned to self.request_version in line 244.

The function which does the response is send_response and at line 402 there is a comparison with HTTP/0.9, this leads to the protocol version is protocol_version is HTTP/1.0 in line 515

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Angularjs http catch block response status is 0 from custom server

From Dev

cURL presents different server response data in output and in trace: why?

From Dev

HTTP request / response with response from a different server

From Dev

How to get response from server using curl in php

From Dev

No response from cURL function

From Dev

PHP cURL - PARSE server response

From Dev

Why proxy server cannot receive response from server

From Dev

Print response JSON from server with HTTP POST

From Dev

how to get the server name from a http response

From Dev

Send HTTP Response from we server to client

From Dev

Why is there no response from iphone after proxy HTTP CONNECT response

From Dev

Create variables from Curl response

From Dev

execute curl command inside php script and get response from server and extract it

From Dev

why there is no response on level 0,1 in ajax (onreadystatechange)

From Dev

why there is no response on level 0,1 in ajax (onreadystatechange)

From Dev

cURL geto no response no error online server

From Dev

No response from SmartFox Server

From Dev

No response from SmartFox Server

From Dev

curl return http_ 400 on image download from a server

From Dev

get all the HTTP headers from HTTP server response in libevent

From Dev

get all the HTTP headers from HTTP server response in libevent

From Dev

How to get the response from URL without cURL?

From Dev

Save Response Body to file from curl request

From Dev

PHP cURL json response from Spotify

From Dev

Resource id #2 response from curl php

From Dev

Retrieving response text from curl in cpp

From Dev

how to add a location header to http response from codeigniter rest server

From Dev

How to remove Server: header from the HTTP response with Apache?

From Dev

Bad HTTP response returned from the server. Code 500

Related Related

  1. 1

    Angularjs http catch block response status is 0 from custom server

  2. 2

    cURL presents different server response data in output and in trace: why?

  3. 3

    HTTP request / response with response from a different server

  4. 4

    How to get response from server using curl in php

  5. 5

    No response from cURL function

  6. 6

    PHP cURL - PARSE server response

  7. 7

    Why proxy server cannot receive response from server

  8. 8

    Print response JSON from server with HTTP POST

  9. 9

    how to get the server name from a http response

  10. 10

    Send HTTP Response from we server to client

  11. 11

    Why is there no response from iphone after proxy HTTP CONNECT response

  12. 12

    Create variables from Curl response

  13. 13

    execute curl command inside php script and get response from server and extract it

  14. 14

    why there is no response on level 0,1 in ajax (onreadystatechange)

  15. 15

    why there is no response on level 0,1 in ajax (onreadystatechange)

  16. 16

    cURL geto no response no error online server

  17. 17

    No response from SmartFox Server

  18. 18

    No response from SmartFox Server

  19. 19

    curl return http_ 400 on image download from a server

  20. 20

    get all the HTTP headers from HTTP server response in libevent

  21. 21

    get all the HTTP headers from HTTP server response in libevent

  22. 22

    How to get the response from URL without cURL?

  23. 23

    Save Response Body to file from curl request

  24. 24

    PHP cURL json response from Spotify

  25. 25

    Resource id #2 response from curl php

  26. 26

    Retrieving response text from curl in cpp

  27. 27

    how to add a location header to http response from codeigniter rest server

  28. 28

    How to remove Server: header from the HTTP response with Apache?

  29. 29

    Bad HTTP response returned from the server. Code 500

HotTag

Archive