如何用Java解析HTTP请求? [英] How to parse an HTTP Request in Java?

查看:590
本文介绍了如何用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

主持人: localhost:54321

Host: localhost:54321

缓存控制:无缓存

有没有一个解析这个请求的内置类?

Is there a built-in class to parse this request?

推荐答案

我对这种解析的内置支持一无所知。如果你真的需要这样的解析器,你可以查看这个lib: 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

这篇关于如何用Java解析HTTP请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆