How to parse an HTTP Request in Java?(如何在 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
这篇关于如何在 Java 中解析 HTTP 请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Java 中解析 HTTP 请求?
基础教程推荐
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
