91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 4KB
    文件類型: .zip
    金幣: 2
    下載: 1 次
    發布日期: 2021-06-11
  • 語言: C#
  • 標簽: HttpClient??

資源簡介

我們知道, .Net類庫里提供了HttpWebRequest等類,方便我們編程與Web服務器進行交互. 但是實際使用中我們經常會遇到以下需求

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.IO;
using?System.Text;
using?System.Net;
using?System.Web;

namespace?Deerchao.Utility
{
????public?class?HttpClient
????{
????????#region?fields
????????private?bool?keepContext;
????????private?string?defaultLanguage?=?“zh-CN“;
????????private?Encoding?defaultEncoding?=?Encoding.UTF8;
????????private?string?accept?=?“*/*“;
????????private?string?userAgent?=?“Mozilla/4.0?(compatible;?MSIE?6.0;?Windows?NT?5.2;?SV1;?.NET?CLR?1.1.4322;?.NET?CLR?2.0.50727)“;
????????private?HttpVerb?verb?=?HttpVerb.GET;
????????private?HttpClientContext?context;
????????private?readonly?List?files?=?new?List();
????????private?readonly?Dictionary?postingData?=?new?Dictionary();
????????private?string?url;
????????private?WebHeaderCollection?responseHeaders;
????????private?int?startPoint;
????????private?int?endPoint;
????????#endregion

????????#region?events
????????public?event?EventHandler?StatusUpdate;

????????private?void?OnStatusUpdate(StatusUpdateEventArgs?e)
????????{
????????????EventHandler?temp?=?StatusUpdate;

????????????if?(temp?!=?null)
????????????????temp(this?e);
????????}
????????#endregion

????????#region?properties
????????///?
????????///?是否自動在不同的請求間保留Cookie?Referer
????????///?

????????public?bool?KeepContext
????????{
????????????get?{?return?keepContext;?}
????????????set?{?keepContext?=?value;?}
????????}

????????///?
????????///?期望的回應的語言
????????///?

????????public?string?DefaultLanguage
????????{
????????????get?{?return?defaultLanguage;?}
????????????set?{?defaultLanguage?=?value;?}
????????}

????????///?
????????///?GetString()如果不能從HTTP頭或meta標簽中獲取編碼信息則使用此編碼來獲取字符串
????????///?

????????public?Encoding?DefaultEncoding
????????{
????????????get?{?return?defaultEncoding;?}
????????????set?{?defaultEncoding?=?value;?}
????????}

????????///?
????????///?指示發出Get請求還是Post請求
????????///?

????????public?HttpVerb?Verb
????????{
????????????get?{?return?verb;?}
????????????set?{?verb?=?value;?}
????????}

????????///?
????????///?要上傳的文件.如果不為空則自動轉為Post請求
????????///?

????????public?List?Files
????????{
????????????get?{?return?files;?}
????????}

????????///?
????????///?要發送的Form表單信息
????????///?

????????public?Dictionary?PostingData
????????{
????????????get?{?return?postingData;?}
????????}

????????///?
????????///?獲取或設置請求資源的地址
????????///?

????????public?string?Url
????????{
????????????get?{?return?url;?}
????????????set?{?url?=?value;?}
????????}

????????///?
????????///?用于在獲取回應后暫時記錄回應的HTTP頭
????????///?

????????public?WebHeaderCollection?ResponseHeaders
????????{
?????????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????21058??2007-08-11?18:27??HttpClient.cs

評論

共有 條評論