当前位置: 首页>>代码示例>>C#>>正文


C# HttpWorkerRequest.GetQueryString方法代码示例

本文整理汇总了C#中System.Web.HttpWorkerRequest.GetQueryString方法的典型用法代码示例。如果您正苦于以下问题:C# HttpWorkerRequest.GetQueryString方法的具体用法?C# HttpWorkerRequest.GetQueryString怎么用?C# HttpWorkerRequest.GetQueryString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.HttpWorkerRequest的用法示例。


在下文中一共展示了HttpWorkerRequest.GetQueryString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseRequest

 /// <summary>
 /// Parses the request into files then parses the files into form fields and uploaded files.
 /// </summary>
 /// <param name="r">The r.</param>
 /// <returns></returns>
 Mapper ParseRequest(HttpWorkerRequest r)
 {
     // get the ID of the upload from the querystring if any
     var qid = r.GetQueryString();
     Guid id;
     if(!Guid.TryParse(qid, out id)) {
         throw new HttpParseException("Upload contains no ID.");
     }
     var d = new HttpUploadStatusEventArgs() {
         Id = id,
         StartedOn = DateTime.Now,
         LastUpdated = DateTime.Now,
         Message = "Beginning Upload."
     };
     var isIdFound = false;
     var isMapFound = false;
     var e = new UTF8Encoding();
     // bytes for "Content-Disposition: form-data; "
     var mapSig = new byte[] {
     67,111,110,116,101,110,116,45,68,105,115,112,111,
     115,105,116,105,111,110,58,32,102,111,114,109,
     45,100,97,116,97,59,32,110,97,109,101,61,
     34,109,97,112,34,13,10,13,10
     };
     var idSig = new byte[] {
     67,111,110,116,101,110,116,45,68,105,115,112,111,115,105,116,105,
     111,110,58,32,102,111,114,109,45,100,97,116,97,59,32,110,
     97,109,101,61,34,105,100,34,13,10,13,10};
     var m = new Mapper();
     // first 46 bytes = boundary signature
     const int f = 131072; // 128kb = 131072b
     var l = r.GetTotalEntityBodyLength();
     d.BytesTotal = l;
     var p = r.GetPreloadedEntityBody();
     var b = GetBoundary(p);
     updateUploadStatus(ref d,l,"Uploading preloaded entity body.");
     // load stream into temp file
     var fst = Path.GetTempFileName();
     using (var fs = new FileStream(fst, FileMode.OpenOrCreate)) {
         // write preloaded body to file
         Debug.Assert(p != null, "GetPreloadedEntityBody != null");
         fs.Write(p, 0, p.Length);
         var c = p.Length;
         var q = 0;
         var u = new byte[f];
         updateUploadStatus(ref d, l, "Uploading.");
         while (l - c > q) {
             q = r.ReadEntityBody(u, 0, f);
             fs.Write(u, 0, q);
             c += q;
             updateUploadStatus(ref d, c, "Uploading.");
         }
         if (l - c > 0) {
             var ux = new byte[l - c];
             q = r.ReadEntityBody(ux, 0, l - c);
             fs.Write(ux, 0, q);
         }
         fs.Flush();
         fs.Position = 0;
         updateUploadStatus(ref d, c, "Upload Complete, Parsing upload.");
         // read the entire file finding all boundaries
         var s = new List<long>();
         while (fs.Position < fs.Length) {
             s.Add(FindPosition(fs, b, fs.Position));
         }
         fs.Position = 0;
         // the last boundary is the eof
         for (var i = 0; s.Count - 1 > i; i++) {
             // indexes between boundaries - this is the new file size in bytes
             if (s[i + 1] == -1) {
                 break;
             }
             var z = s[i + 1] - s[i];
             // this is the size of the object between the boundaries (including current boundary)
             var g = (z) < f ? z : f;
             // chunk size (g) = 131072 (f) or next boundary pos - current boundary pos (z)
             var n = Path.GetTempFileName();
             fs.Position = s[i]; // start reading from the beginning position of the object (including boundary)
             using (var a = new FileStream(n, FileMode.OpenOrCreate)) {
                 q = 0;
                 c = 0;
                 while (z - c > q) {
                     //read blocks while position - mod block size  is less than end position
                     q = fs.Read(u, 0, (int)g);
                     a.Write(u, 0, q);
                     c += q;
                 }
                 q = fs.Read(u, 0, (int)z - c);
                 a.Write(u, 0, q);
                 a.Position = 0;
                 // read in form data
                 if (!isMapFound) {
                     if (FindPosition(a, mapSig, 0) > -1) {
                         // this is the map field
                         var mapBytes = new byte[a.Length - a.Position - 2]; // -2 to drop the \r\n
//.........这里部分代码省略.........
开发者ID:CorbinDallas,项目名称:Oda,代码行数:101,代码来源:ParseRequest.cs


注:本文中的System.Web.HttpWorkerRequest.GetQueryString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。