本文介绍了如何捕获HTTP请求/响应流量结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用c#Windows Form App手动捕获Http请求/响应流量结果(URL,方法,类型等)。

I want to Capture Http Request/Response Traffic results(URL,Method,Type etc) with c# Windows Form App as manually.

示例:
运行ie explorer->工具-> F12开发人员工具-> Network Tab-Star Capture

An Example :Run ie explorer-> Tools -> F12 Developer Tools->Network Tab-Star Capture

如何解决此问题。 (是否使用sdk,winpcap等)
如何跟踪道路?

How can I solve this problem. (Any use of the sdk. winpcap etc)How to trace a road?

推荐答案

请尝试以下操作:

...
HttpWebRequest request =(HttpWebRequest)WebRequest.Create(HttpUtility.UrlDecode(<url>));
...
try
{
     HttpWebResponse response =(HttpWebResponse)request.GetResponse();
     WebHeaderCollection headers = response.Headers;
     ...
}
catch(WebException exc) { "HTTP EXCEPTION: " + exc.Message +" " + exc.Status; }
catch(ProtocolViolationException exc) { exc.Message; }
catch(UriFormatException exc)         { exc.Message; }
catch(NotSupportedException exc)      { exc.Message; }
catch(IOException exc)                { exc.Message; }

这篇关于如何捕获HTTP请求/响应流量结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-11 21:03