是否有可能改变头订购使用HttpWebRequest的? [英] Is it possible to change headers order using HttpWebRequest?

查看:195
本文介绍了是否有可能改变头订购使用HttpWebRequest的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要改变头的顺序,我用这样的:

I need to change the order of headers, I'm using this:

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);
request.Method = context.Request.HttpMethod;
request.UserAgent = context.Request.UserAgent;

有关的输出是:

GET /* HTTP/1.1
User-Agent: My Server
Host: 127.0.0.1:1080

但它应该是

GET /* HTTP/1.1
Host: 127.0.0.1:1080
User-Agent: My Server

任何想法

感谢您的时间

编辑:
也许有使用其他对象的方法......这也是一种选择

Maybe there's a way using other object ... it's also an option

推荐答案

有是一位杰出的抱怨,.NET不会让你修改主机头而回。它可能没有得到解决。如果是的真正的那么重要,你总是可以写套接字级别的代码,将准备好的请求(因为它只是文本)。

There was an outstanding complaint that .NET doesn't let you modify the Host header a while back. It might not have been resolved. If it is really that important, you could always write socket-level code to send a prepared request (since it's just text).

这篇关于是否有可能改变头订购使用HttpWebRequest的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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