简体   繁体   English

我应该使用字节流还是字符流来处理HTTP消息?

[英]Should I use byte streams or character streams to handle HTTP messages?

I am writing a proxy server (college assignment). 我正在编写代理服务器(学院作业)。 I've searched for example source code and it seems there are two extremes: byte stream user and character stream user. 我搜索了示例源代码,似乎有两个极端:字节流用户和字符流用户。

From what I know, HTTP messages use ASCII encoding for only the request line (request), the status line (response) and the field names and allow any octet in the field values and request body. 据我所知,HTTP消息仅对请求行(请求),状态行(响应)和字段名称使用ASCII编码,并允许在字段值和请求正文中使用任何八位位组。

So, what is the right way? 那么,正确的方法是什么?

Byte streams are the correct way. 字节流是正确的方法。 Imagine forwarding a zip file download and parsing the content with a character stream... 想象一下转发一个zip文件下载并使用字符流解析内容...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM