0

我正在尝试调试在我们的服务器上产生错误的 HTTP 请求。但是,我正在努力以某种方式重现确切的请求。

在我的 nginx 日志中,我看到了这个生成错误的条目

157.55.33.20 - - [22/Nov/2013:04:06:22 +0000] "GET /en/library/search?utf8=\xE2\x9C\x93&q=something HTTP/1.1" 500 0 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)" "-"

但是,尝试使用curlhttpie使用相同的字符串会产生如下日志条目:

GET /en/library/search?utf8=\x5CxE2\x5Cx9C\x5Cx93&q=something

或者

GET /en/library/search?utf8=xE2x9Cx93&q=something

或者

GET /en/library/search?utf8=%5CxE2%5Cx9C%5Cx93&q=something

我似乎无法重现完全相同的请求。我尝试了各种命令行参数,但无法弄清楚这一点。

有关如何重现完全相同的请求的任何建议?

4

4 回答 4

2

在我看来,\xE2\x9C\x93 是您的服务器重新编码的实际 UTF8 字符,以便能够将它们放入日志中。也许看看 UTF8 中的字符实际上是什么,并将字符放在 URL 中。

希望能帮助到你

于 2013-11-22T20:02:14.093 回答
1

You can create HTTP requests with greater freedom with telnet. To start a connection, type this at the command line:

telnet www.example.com 80

(Here, 80 corresponds to the port number for HTTP requests). Once you're connected, you'll see a message like this:

Trying 12.34.56.78...
Connected to www.example.com.
Escape character is '^]'.

You can then type in your request, e.g.:

GET /en/library/search?utf8=\xE2\x9C\x93&q=something HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

Finish with two carriage returns to mark the end of the header.

EDIT: lcornea's suggestion is also worth considering. If your command line terminal accepts UTF8 (type in echo $LANG to find out), then type (or paste) the character ✓ (check mark) instead of the three escaped characters. Or on a Windows Latin-1 terminal, type in ✓ instead.

于 2013-11-22T20:08:10.723 回答
0

而不是\xYZ使用%YZ,它将是相同的。例如在 CURL 请求中替换\xE2为。%E2

于 2013-11-22T20:00:20.270 回答
0

您是否尝试过: curl -s -o /dev/null " http://yoursite.com/en/library/search?utf8= \xE2\x9C\x93&q=something" ?

于 2013-11-22T20:07:09.233 回答