当我在C语言中使用以下GET HTTP请求时,我一直收到400 Bad Request
的错误提示,但是当我使用字符串形式的IP地址(例如:www.wwe.com/index.php)时,它可以正常工作:
GET %s HTTP/1.0\r\nHost: %s\r\nConnection: Keep-Alive\r\n\r\n
在GET后的%s将被替换为类似以下内容:
http://54.236.192.188/index.php
,而Host值则由hostent结构中的h_name字符串值提供。因此,请求看起来像这样:
GET http://54.236.192.188/index.php HTTP/1.0
Host: ec2-54-236-192-188.compute-1.amazonaws.com
Connection: Keep-Alive
这里我做错了什么?