如何开发HTTP标头视图工具 [英] How to develop a HTTP header view tool

查看:68
本文介绍了如何开发HTTP标头视图工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我想开发一个工具来查看HTTP标头信息.你能给我一些想法吗?

I want to develop a tool to view the HTTP header information. Could you please give me some ideas?

谢谢.

刘明

推荐答案

只需使用HTTPwebRequest和webresponse class

Simply use the HTTPwebRequest and webresponse  class

                        Dim wbRq As HttpWebRequest = DirectCast(WebRequest.Create(targetUrl), HttpWebRequest)
                        wbRq.Timeout = 2000
                        Try
                            Dim wbRs As HttpWebResponse = DirectCast(wbRq.GetResponse(), HttpWebResponse)
                            Dim wbHCol As WebHeaderCollection = wbRs.Headers
                            For y As Integer = 0 To wbHCol.Count - 1
                                Dim header As String = wbHCol.GetKey(y)
                                Dim values As String() = wbHCol.GetValues(header)
                                If values.Length > 0 Then
                                    Select Case header.ToLower
                                        Case "content-type"
                                            theUrlContentType = values(0)
                                        Case "content-length"
                                            theUrlFileSize = values(0)
                                    End Select
                                End If
                            Next
                            wbRs.Close()


这篇关于如何开发HTTP标头视图工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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