将原始 HTTP 请求转换为 HTTPWebRequest 对象 [英] Converting Raw HTTP Request into HTTPWebRequest Object

查看:42
本文介绍了将原始 HTTP 请求转换为 HTTPWebRequest 对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 .NET 中是否可以将原始 HTTP 请求转换为 HTTPWebRequest 对象?

In .NET is it possible to convert a raw HTTP request to HTTPWebRequest object?

我确信 .NET 内部会这样做.知道 .NET 的哪一部分实际上在处理这个问题吗?我可以调用它还是有任何允许原始 HTTP 连接的外部库?

I'm sure .NET internally doing it. Any idea which part of the .NET is actually handling this? Can I call it or is there any external library which allows raw HTTP connections?

推荐答案

我不相信有公开的方法可以做到这一点.您可能需要找到或编写一个解析器来分解请求,然后编写您自己的扩展 HttpWebRequest 的类.

I dont believe there is an exposed method to do this. You may have to find or write a parser to break the request up and then write your own class that extends HttpWebRequest.

这是来自 CodeProject 的解析器:

Here is what looks like a parser from CodeProject:

http://www.codeproject.com/KB/IP/CSHTTPServer.aspx

我查看了 HttpWebRequest 的转子代码(简要),我没有看到任何突出的银弹.这是文件的链接:

I looked at the rotor code for the HttpWebRequest (briefly) and I did not see anything that stood out as a silver bullet. Here is the link to the file:

http://www.123aspx.com/Rotor/RotorSrc.aspx?腐烂=40844

所有转子代码都在这里在线浏览:

All of the rotor code is here for browsing online:

http://www.123aspx.com/Rotor/default.aspx

您可以在这里下载:

http://www.microsoft.com/downloads/details.aspx?FamilyId=8C09FD61-3F26-4555-AE17-3121B4F51D4D&displaylang=en

我知道一堆链接并不能真正回答您的问题,但我认为您正在寻找的功能并未在框架中公开.我很想被证明是错误的,所以如果你找到一个好的方法,请更新帖子.我知道那里的工具必须这样做,任何用 .Net 编写的记录原始请求然后让您重新提交它们的东西都在做类似的事情.我相信 fiddler (http://www.fiddler2.com) 是用 .Net 编写,您可能想向这些人发送电子邮件,看看他们是否可以提供帮助.

I know a bunch of links doesn't really answer your question, but I don't think the functionality that you are looking for is exposed in the framework. I would love to be proven wrong, so please update the post if you find a good way of doing it. I know tools out there must do it, anything written in .Net that logs raw requests and then lets you resubmit them is doing something similar. I believe fiddler (http://www.fiddler2.com) is written in .Net, you may want to shoot an email over to those guys and see if they can help.

这篇关于将原始 HTTP 请求转换为 HTTPWebRequest 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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