如何在 Java 中解析 HTTP 请求?
在实现代理服务器时,我得到一个字符串形式的 HTTP 请求,比如这个:
When implementing a proxy server, I get an HTTP request as a string, such as this one:
GET http://localhost:54321/x HTTP/1.1
GET http://localhost:54321/x HTTP/1.1
主机:本地主机:54321
Host: localhost:54321
缓存控制:无缓存
是否有一个内置类来解析这个请求?
Is there a built-in class to parse this request?
推荐答案
我对这种解析的内置支持一无所知.如果你真的需要这样的解析器,你可以查看这个库:http://hc.apache.org/index.html
I don't know anything about built-in support for such parsing. If you really need such parser, you can check out this lib: http://hc.apache.org/index.html
这里有详细的例子:http://www.mail-archive.com/httpclient-user@jakarta.apache.org/msg04070.html
相关文章