资源简介
接收发送HTTP协议报文数据,非常不错的源代码
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Collections;
using System.IO;
using System.Text.Regularexpressions;
using RE = System.Text.Regularexpressions.Regex;
using System.Security.Cryptography.X509Certificates;
namespace HTTP
{
///
///上传事件委托
///
///
///
public delegate void WebClientUploadEvent(object sender HTTP.UploadEventArgs e);
///
///下载事件委托
///
///
///
public delegate void WebClientDownloadEvent(object sender HTTP.DownloadEventArgs e);
///
///上传事件参数
///
public struct UploadEventArgs
{
///
///上传数据总大小
///
public long totalBytes;
///
///已发数据大小
///
public long bytesSent;
///
///发送进度(0-1)
///
public double sendProgress;
///
///发送速度Bytes/s
///
public double sendSpeed;
}
///
///下载事件参数
///
public struct DownloadEventArgs
{
///
///下载数据总大小
///
public long totalBytes;
///
///已接收数据大小
///
public long bytesReceived;
///
///接收数据进度(0-1)
///
public double ReceiveProgress;
///
///当前缓冲区数据
///
public byte[] receivedBuffer;
///
///接收速度Bytes/s
///
public double receiveSpeed;
}
///
///实现向WEB服务器发送和接收数据
///
public class WebClient
{
private WebHeaderCollection requestHeaders responseHeaders;
private TcpClient clientSocket;
private MemoryStream postStream;
private Encoding encoding = Encoding.Default;
private const string BOUNDARY = “--HEDAODE--“;
private const int SEND_BUFFER_SIZE = 10245;
private const int RECEIVE_BUFFER_SIZE = 10245;
private string cookie = ““;
private string respHtml = ““;
private string strRequestHeaders = ““;
private string strResponseHeaders = ““;
private int statusCode = 0;
private bool isCanceled = false;
public event WebClientUploadEvent UploadProgressChanged;
public event WebClientDownloadEvent DownloadProgressChanged;
///
///初始化WebClient类
///
public WebClient()
{
responseHeaders = new WebHeaderCollection();
requestHeaders = new WebHeaderCollection();
}
相关资源
- 如何在WPF应用程序中通过HttpClient调用
- C# HttpHelper.cs
- C# httplistener 简单的高并发http服务器
- C#网络应用编程第三版马骏主编上机练
- C#版支持高并发的HTTP服务器源码
- ASP.NET System.Web.Http.dll
- C# Http协议上传文件有进度条
- WinformC# 模拟登陆百度 HttpWebRequest的应
- c#下的http请求通用类(自动实现保留
- C#通过winform和http上传文件
- C#HTTPclient 应用
- httpclient source code by csharp
- Multipart解析类库源码(HttpMultipart)
- 谷歌插件直接通过C#安装
- http报文抓取工具源码
- C#通过HTTP协议get、post Webservice并返回
- 图片上传.rarC#如何使用input[type=file]进
- C# HttpServer 实现
- unity通过http发送和接收数据14926
- C#网络应用编程实验 WCF和HTTP文件传输
- 读取WebBrowser中的Cookies(含Session)信
- HttpFtp上传, 加载条Demo
- 读取webbrowser 中的 cookies 到 httpwebreq
- LumiSoft.Net网络编程最全的类(c#)含
- httpLib网络操作通用类采集,支持get
- C# 非常强大的web请求类 HttpClient项目源
- c# 扫描IP Http Header
- HttpHelper类,用来实现Http访问,Post或
- C# 模拟请求HttpWebRequest 类源码
- c# 多线程
评论
共有 条评论