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


C# Request类代码示例

本文整理汇总了C#中Request的典型用法代码示例。如果您正苦于以下问题:C# Request类的具体用法?C# Request怎么用?C# Request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: InitializeProvider

 /// <summary>
 ///     Performs one-time initialization of the PROVIDER.
 /// </summary>
 /// <param name="request">
 ///     An object passed in from the CORE that contains functions that can be used to interact with
 ///     the CORE and HOST
 /// </param>
 public void InitializeProvider(Request request) {
     if( request == null ) {
         throw new ArgumentNullException("request");
     }
     // Nice-to-have put a debug message in that tells what's going on.
     request.Debug("Calling '{0}::InitializeProvider'", ProviderName);
 }
开发者ID:vairam-svs,项目名称:oneget,代码行数:14,代码来源:MsiProvider.cs

示例2: Fail

        private static AppFunc Fail(int status, string body, string headerName = null, string headerValue = null)
        {
            return env =>
                {
                    Request request = new Request(env);
                    Response response = new Response(env);
                    response.StatusCode = status;
                    response.Headers
                        .SetHeader("Content-Type", "text/plain")
                        .SetHeader("Content-Length", body.Length.ToString(CultureInfo.InvariantCulture))
                        .SetHeader("X-Cascade", "pass");

                    if (headerName != null && headerValue != null)
                    {
                        response.Headers.SetHeader(headerName, headerValue);
                    }

                    if ("HEAD".Equals(request.Method, StringComparison.OrdinalIgnoreCase))
                    {
                        return TaskHelpers.Completed();
                    }

                    return response.WriteAsync(body);
                };
        }
开发者ID:majimenezp,项目名称:gate,代码行数:25,代码来源:FileServer.cs

示例3: Request

        public override Request Request(Request request)
        {
            // (collectionPointer)(key:binary)(inclusive:boolean)(pageSize:int)
            base.Request(request);

            request.OperationMode = OperationMode.Synchronous;

            // collection pointer
            request.AddDataItem(FileId);
            request.AddDataItem(PageIndex);
            request.AddDataItem(PageOffset);

            // key binary
            var cid = BinarySerializer.ToArray(FirstKey.ClusterId);
            var cpos = BinarySerializer.ToArray(FirstKey.ClusterPosition);
            byte[] orid = new byte[cid.Length + cpos.Length];
            Array.Copy(cid, orid, cid.Length);
            Array.Copy(cpos, 0, orid, cid.Length, cpos.Length);
            request.AddDataItem(orid);

            // inclusive
            request.AddDataItem((byte)(Inclusive ? 1 : 0)); // 0 - false 1 - true

            // page size
            if (OClient.ProtocolVersion >= 21)
                request.AddDataItem((int)128);

            return request;
        }
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:29,代码来源:SBTreeBonsaiGetEntriesMajor.cs

示例4: Request

        public override Request Request(Request request)
        {
            base.Request(request);

            request.AddDataItem(ConfigKey);
            return request;
        }
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:7,代码来源:ConfigGet.cs

示例5: StartListening

        public void StartListening()
        {
            while (true)
            {
                using (Socket clientSocket = listeningSocket.Accept())
                {
                    IPEndPoint clientIP = clientSocket.RemoteEndPoint as IPEndPoint;
                    Debug.Print("Received request from " + clientIP.ToString());
                    var x = clientSocket.RemoteEndPoint;

                    int availableBytes = clientSocket.Available;
                    Debug.Print(DateTime.Now.ToString() + " " + availableBytes.ToString() + " request bytes available");

                    int bytesReceived = (availableBytes > maxRequestSize ? maxRequestSize : availableBytes);
                    if (bytesReceived > 0)
                    {
                        byte[] buffer = new byte[bytesReceived]; // Buffer probably should be larger than this.
                        int readByteCount = clientSocket.Receive(buffer, bytesReceived, SocketFlags.None);

                        using (Request r = new Request(clientSocket, Encoding.UTF8.GetChars(buffer)))
                        {
                            Debug.Print(DateTime.Now.ToString() + " " + r.URL);
                            if (requestReceived != null) requestReceived(r);

                        }

                    }
                }

                // I always like to have this in a continuous loop. Helps prevent lock-ups
                Thread.Sleep(10);
            }
        }
开发者ID:Ckubit,项目名称:Netduino,代码行数:33,代码来源:Listener.cs

示例6: Create

        /// <summary>
        /// Create a Parcel.
        /// </summary>
        /// <param name="parameters">
        /// Dictionary containing parameters to create the parcel with. Valid pairs:
        ///   * {"length", int}
        ///   * {"width", int}
        ///   * {"height", int}
        ///   * {"weight", double}
        ///   * {"predefined_package", string}
        /// All invalid keys will be ignored.
        /// </param>
        /// <returns>EasyPost.Parcel instance.</returns>
        public static Parcel Create(IDictionary<string, object> parameters)
        {
            Request request = new Request("parcels", Method.POST);
            request.addBody(parameters, "parcel");

            return request.Execute<Parcel>();
        }
开发者ID:dmmatson,项目名称:easypost-csharp,代码行数:20,代码来源:Parcel.cs

示例7: RetrieveReference

        /// <summary>
        /// Retrieve a Item from a custom reference.
        /// </summary>
        /// <param name="name">String containing the name of the custom reference to search for.</param>
        /// <param name="value">String containing the value of the custom reference to search for.</param>
        /// <returns>EasyPost.Item instance.</returns>
        public static Item RetrieveReference(string name, string value) {
            Request request = new Request("items/retrieve_reference/?{name}={value}");
            request.AddUrlSegment("name", name);
            request.AddUrlSegment("value", value);

            return request.Execute<Item>();
        }
开发者ID:andyfengc,项目名称:Demo_.Net,代码行数:13,代码来源:Item.cs

示例8: MXLookup

        public static MXRecord[] MXLookup(string domain, IPAddress dns_server) {
            
            // check the inputs
            if (domain == null || dns_server == null)
                throw new ArgumentNullException((domain == null) ? "dns_server" : "domain");

            // create a request for this
            Request request = new Request();

            // do the MX IN lookup for the suplied domain
            request.AddQuestion(new Question(domain, DnsType.MX, DnsClass.IN));
            Response response = Lookup(request, dns_server);

            if (response == null)
                return null;

            List<MXRecord> resource_records = new List<MXRecord>();
            foreach(Answer answer in response.Answers) {
                if (answer.Record is MXRecord) {
                    resource_records.Add(answer.Record as MXRecord);
                }
            }

            // sort into lowest preference order
            resource_records.Sort();

            return resource_records.ToArray();
        }
开发者ID:joethinh,项目名称:nohros-must,代码行数:28,代码来源:resolver.cs

示例9: HandleRequest

        public override void HandleRequest(Request request)
        {
            if (request.Message.StartsWith("~geoip") && request.RequestFrom.AccessLevel >= AccessLevel.Public)
            {
                Match expressionMatch = GeoIpRegex.Match(request.Message);

                if (expressionMatch.Success)
                {
                    try
                    {
                        ExecuteSearch(expressionMatch.Groups[1].Value, request);
                    }
                    catch (Exception ex)
                    {

                        ModuleManagementContainer.HandleResponse(request.CreateResponse(ResponseType.Public,
                                                                 "{0}, The service is currently b00rked, please try again in a few minutes.", request.Nick));
                        Logger.WarnFormat("Search threw an exception. Nick: {0}, terms: \"{1}\", stack message: {2}",
                                          request.Nick, expressionMatch.Groups[1].Value, ex.StackTrace);
                    }

                }
                else
                {
                    // If the message format isn't correct, notify the user.
                    ModuleManagementContainer.HandleResponse(request.CreateResponse(ResponseType.Public,
                                                                                    String.Format("{0}, invalid geoip syntax, please try again.",
                                                                                    request.Nick)));
                }
            }
        }
开发者ID:rpk,项目名称:SpikeLite,代码行数:31,代码来源:GeoIpLookupModule.cs

示例10: HandleRequest

        static void HandleRequest(Request request, Response response)
        {
            // receive HTTP content
            byte[] content = request.Stdin.GetContents();

            // access server variables
            string serverSoftware = request.ServerSoftware.GetValueOrDefault();
            string method = request.RequestMethod.Value;

            // access HTTP headers
            string userAgent = request.Headers[RequestHeader.HttpUserAgent];
            string cookieValue = request.GetCookieValue("Keks").GetValueOrDefault();

            // set HTTP headers
            response.SetHeader(ResponseHeader.HttpExpires,
                               Response.ToHttpDate(DateTime.Now.AddDays(1.0)));
            response.SetCookie(new Cookie("Keks", "yummy"));

            // send HTTP content
            response.PutStr(
                @"<html>
                   <body>
                    <p>Hello World!</p>
                    <p>Server: " + serverSoftware + @"</p>
                    <p>User Agent: " + userAgent + @"</p>
                    <p>Received cookie value: " + cookieValue + @"</p>
                    <p>Content length as read: " + content.Length + @"</P>
                    <p>Request method: " + method + @"</p>
                   </body>
                  </html>"
                );
        }
开发者ID:wmeyer,项目名称:SharpCGI,代码行数:32,代码来源:Program.cs

示例11: Get

        internal ArangoCollection Get(string name)
        {
            var request = new Request(RequestType.Collection, HttpMethod.Get);
            request.RelativeUri = string.Join("/", _apiUri, name);

            var response = _connection.Process(request);
            var collection = new ArangoCollection();

            switch (response.StatusCode)
            {
                case HttpStatusCode.OK:
                    collection.Id = response.Document.String("id");
                    collection.Name = response.Document.String("name");
                    collection.Status = response.Document.Enum<ArangoCollectionStatus>("status");
                    collection.Type = response.Document.Enum<ArangoCollectionType>("type");
                    break;
                case HttpStatusCode.NotFound:
                    collection = null;
                    break;
                default:
                    if (response.IsException)
                    {
                        throw new ArangoException(
                            response.StatusCode,
                            response.Document.String("driverErrorMessage"),
                            response.Document.String("driverExceptionMessage"),
                            response.Document.Object<Exception>("driverInnerException")
                        );
                    }
                    break;
            }

            return collection;
        }
开发者ID:jsteemann,项目名称:ArangoDB-NET,代码行数:34,代码来源:CollectionOperation.cs

示例12: OnFailure

 public void OnFailure(Request request, Java.IO.IOException exception)
 {
     if (onFailure != null)
     {
         onFailure(request, exception);
     }
 }
开发者ID:monostefan,项目名称:square-bindings,代码行数:7,代码来源:Call.cs

示例13: Handle

        /// <summary>
        /// Tries to handle request.
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The WebServer.BusinessLogic.Response.
        /// </returns>
        public override Response Handle(Request request)
        {
            if (request.HttpPath.EndsWith("/"))
            {
                string path = Configurator.Instance.RelativeWwwPath + request.HttpPath.Replace("/", "\\");
                if(!Directory.Exists(path))
                {
                    return NextHandler.Handle(request);
                }
                DirectoryInfo directory = new DirectoryInfo(path);
                List<FileSystemInfo> descendants = new List<FileSystemInfo>();
                descendants.AddRange(directory.GetFileSystemInfos());

                if (descendants.Select(desc => desc.Name).Contains("index.html"))
                {
                    request.HttpPath += "index.html";
                    return NextHandler.Handle(request);
                }

                string webPage = this.CreateWebPage(descendants, request);

                Response toReturn = new Response("text/html", request.HttpVersion, Encoding.UTF8.GetBytes(webPage));
                if (Configurator.Instance.UseResponseCompression && request.AcceptEncoding == EnumAcceptEncoding.Gzip)
                {
                    toReturn.Data = GzipCompress(toReturn.Data);
                    toReturn.ContentEncoding = "gzip";
                }

                return toReturn;
            }

            return NextHandler.Handle(request);
        }
开发者ID:taraspikh,项目名称:cs-webserver,代码行数:42,代码来源:DirectoryHandler.cs

示例14: ExtractCredentialsFromHeaders

        private static string[] ExtractCredentialsFromHeaders(Request request)
        {
            var authorization =
                request.Headers.Authorization;

            if (string.IsNullOrEmpty(authorization))
            {
                return null;
            }

            if (!authorization.StartsWith(SCHEME))
            {
                return null;
            }

            try
            {
                var encodedUserPass = authorization.Substring(SCHEME.Length).Trim();
                var userPass = Encoding.UTF8.GetString(Convert.FromBase64String(encodedUserPass));

                return String.IsNullOrWhiteSpace(userPass) ? null : userPass.Split(':');
            }
            catch (FormatException)
            {
                return null;
            }
        }
开发者ID:kppullin,项目名称:Nancy,代码行数:27,代码来源:BasicAuthentication.cs

示例15: Delete

        internal bool Delete(string id)
        {
            var request = new Request(RequestType.Edge, HttpMethod.Delete);
            request.RelativeUri = string.Join("/", _apiUri, id);

            var response = _connection.Process(request);
            var isRemoved = false;

            switch (response.StatusCode)
            {
                case HttpStatusCode.OK:
                case HttpStatusCode.Accepted:
                    isRemoved = true;
                    break;
                default:
                    if (response.IsException)
                    {
                        throw new ArangoException(
                            response.StatusCode,
                            response.Document.String("driverErrorMessage"),
                            response.Document.String("driverExceptionMessage"),
                            response.Document.Object<Exception>("driverInnerException")
                        );
                    }
                    break;
            }

            return isRemoved;
        }
开发者ID:jocull,项目名称:ArangoDB-NET,代码行数:29,代码来源:EdgeOperation.cs


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