private static void AddWorkTask(RequestData requestData) { if (requestData.SafeRequestUrl.Length > 3 && !RequestCheck.IsNotSafeRequest(requestData.SafeRequestUrl)) { HttpWorker.EndRequest(requestData.Socket, 400, "Path:" + requestData.SafeRequestUrl); requestData.SaveToPoll(); return; } string fileExt = CommonUtil.GetFileExtention(requestData.SafeRequestUrl); if (!string.IsNullOrEmpty(fileExt)) { fileExt = fileExt.ToLower(); } #region 静态文件请求处理 if (!string.IsNullOrEmpty(fileExt) && !_dynamicReqDic.ContainsKey(fileExt) && requestData.HttpMethod == "GET") { HttpWorker httpWorker = new HttpWorker(); if (httpWorker.Process(requestData)) { return; } } #endregion #region 动态请求处理 if (ApplicationInfo.OwinAdapter != null) { if ((requestData.HttpMethod == "POST" || requestData.HttpMethod == "PUT") && requestData.HeadDomainDic != null && requestData.HeadDomainDic.Keys.Contains("Expect")) { //http 100-continue用于客户端在发送POST数据给服务器前,征询服务器情况,看服务器是否处理POST的数据,如果不处理,客户端则不上传POST数据,如果处理,则POST上传数据。在现实应用中,通过在POST大数据时,才会使用100-continue协议。 Client发送Expect:100-continue消息 //在使用curl做POST的时候, 当要POST的数据大于1024字节的时候, curl并不会直接就发起POST请求, 而是会分为俩步, //1. 发送一个请求, 包含一个Expect:100-continue, 询问Server使用愿意接受数据 //2. 接收到Server返回的100-continue应答以后, 才把数据POST给Server //大致功能好像是当post数据超过1024时,不用询问服务器是否接受其他数据 string text2 = requestData.HeadDomainDic["Expect"].FirstOrDefault <string>(); if (string.Equals(text2, "100-continue", StringComparison.OrdinalIgnoreCase)) { requestData.Socket.Write(Continue100, WriteCallBack, null); requestData.HeadDomainDic.Remove("Expect"); } } OwinAdapterManage owinAdapterManage = new OwinAdapterManage(); if (owinAdapterManage.Process(requestData)) { return; } } #endregion #region 请求Info信息 if (requestData.SafeRequestUrl == "/info") { SendWelcomePage((OwinSocket)requestData.Socket, requestData); return; } #endregion HttpWorker.EndRequest(requestData.Socket, 404, requestData.RequestUrl); requestData.SaveToPoll(); }