python - 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.
解决方案
推荐阅读
- django - 使用 django-haystack 的 Elasticsearch 自动运行更新索引
- php - php.ini 未在 Ubuntu 16.04.3 LTS 上重新加载
- html - 通过 HTML 方式调整大小的图像比通过 PhotoShop 更清晰
- git - 即使在新的克隆存储库中,Github 桌面也会在 >>> HEAD 中恢复提交结果
- php - 在 Laravel 中将引导程序的版本从 4 更改为 3
- sql-server - 如何使用 T-SQL 在多列查询中使用计数表填充 0
- javascript - 当用户不点击按钮时如何计算?
- python-3.x - 如何从 gspread 访问单元格值
- c++ - C++ 中的回文扫描器
- ios - 无法获得 UIVew 尺寸