无法从命令行卷曲

时间:2014-08-19 22:55:45

标签: bash unix curl wget

也许是一个非常幼稚的问题..让我说我有一个网址

http://localhost:8088/querty?q=r8

我可以从浏览器访问上面的网址,但是当我做wget或curl时

curl -o /dev/null --silent --head --write-out '%{http_code}' "http://localhost:8088 给了000

wget "http://localhost:8088/querty?q=r8" 

给出

--2014-08-19 15:55:03--  (try: 7)  http://localhost:8088/querty?q=r8
Connecting to localhost|127.0.0.1|:8088... connected.
HTTP request sent, awaiting response... No data received.
Retrying.

我看不到回应

无法理解发生了什么事?

编辑:

Response from verbose flag:
* Adding handle: conn: 0x7f8ad3804400
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7f8ad3804400) send_pipe: 1, recv_pipe: 0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* About to connect() to localhost port 8088 (#0)
*   Trying ::1...
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 8088 (#0)
> HEAD /querty?q=r8 HTTP/1.1
> User-Agent: curl/7.30.0
> Host: localhost:8088
> Accept: */*
>
* Empty reply from server
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
* Connection #0 to host localhost left intact
curl: (52) Empty reply from server

1 个答案:

答案 0 :(得分:2)

看起来您正在获得响应,只是响应中没有数据。 (也就是说,'空的回复'而不是“没有回复”。)

Google搜索curl 52 empty reply from serverwget "no data received"会产生各种各样的线索,其中包含可能出现这种情况的各种原因 - 也就是说,从目前为止的数据来看,我并不相信清楚 - 切割根本原因尚可识别。

例如,一个repro位于服务器上,其中--header="accept-encoding: gzip"请求添加wget是解决方案 - 这可能适合您的方案,因为浏览器可能会添加此类标头,而手动curlwget尝试不会。

另一个想法(我在类似的调试情况下使用它)是使用lynx - 它是一个终端浏览器,它带有一些额外的类似浏览器的行为,有时更难以通过curlwget实现。 (例如,在页面的URL上下文中解释相对href链接 - 这在此处不相关,但您明白了。)这样看起来像lynx -source "http://localhost:8088"。< / p>

相关问题