首页 > 解决方案 > No body in answer of GET request

问题描述

I am trying to send the following HTTP GET request:
GET /test-page/ HTTP/1.1
Host: ##my-server-ip##

The answer I receive contains no body :

received data: HTTP/1.1 200 OK
Date: Wed, 11 Jul 2018 17:40:35 GMT
Server: Apache/2.4.10 (Debian)
Last-Modified: Wed, 11 Jul 2018 17:40:20 GMT
ETag: "25-570bcbd95c140"
Accept-Ranges: bytes
Content-Length: 37
Content-Type: text/html

Here is the full python code who makes the request :

import socket
import ssl
addr = ('##server-ip##',443)
BUFFER_SIZE = 2048
MESSAGE = "GET /test-page/ HTTP/1.1\r\nHost: ##server-ip##\r\n\r\n"
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
ss = ssl.wrap_socket(s,ssl_version=ssl.PROTOCOL_TLSv1_2)
ss.connect(addr)
ss.send(MESSAGE)
data = ss.recv(BUFFER_SIZE)
ss.close()
print "received data:", data

When I go with Firefox on this page I get the correct body of course... What is happening please ?

Thank you.

标签: pythonhttpgetrequest

解决方案


推荐阅读