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


C# IHttpClientContext类代码示例

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


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

示例1: PollServiceHttpRequest

 public PollServiceHttpRequest(PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext, IHttpRequest pRequest)
 {
     PollServiceArgs = pPollServiceArgs;
     HttpContext = pHttpContext;
     Request = pRequest;
     RequestTime = System.Environment.TickCount;
 }
开发者ID:ChrisD,项目名称:opensim,代码行数:7,代码来源:PollServiceHttpRequest.cs

示例2: CopyHandler

        void CopyHandler(IHttpClientContext context, IHttpRequest request, IHttpResponse response)
        {
            string username;
            if (server.AuthenticateRequest(request, response, out username))
            {
                //parse Destination from header
                //this is required for the copy command
                string[] destinations = request.Headers.GetValues("destination");
                if (destinations == null)
                {
                    response.Status = HttpStatusCode.BadRequest;
                    return;
                }
                string destination = destinations[0];

                //If the client includes a Depth header with an illegal value, the server should return 400 Bad Request.
                //this means that if the resource is a collection, then depth should be infinity
                //and if resource is not a collection, then the depth should be 0
                //if the depth doesn't exist, then proceed normally
                DepthHeader depth = DepthHeader.Infinity; //this is the standard default
                if (request.Headers["depth"] != null)
                {
                    depth = Depth.ParseDepth(request);
                }

                //parse Overwrite header
                //possible values: 'T' or 'F' (true or false)
                //otherwise return 400 Bad Request
                //if value is F and destination already exists, fail with response 412 Precondition Failed
                //default for this value is T
                bool overwrite = true;
                string[] overwrites = request.Headers.GetValues("overwrite");
                if (overwrites != null)
                {
                    if (overwrites[0].ToLower() == "t")
                        overwrite = true;
                    else if (overwrites[0].ToLower() == "f")
                        overwrite = false;
                    else
                    {
                        response.Status = HttpStatusCode.BadRequest;
                        return;
                    }
                }

                //If header might contain lock tokens, we need to pass them forward too
                string[] ifHeaders = request.Headers.GetValues("if");

                Dictionary<String, HttpStatusCode> multiStatusValues = null;
                HttpStatusCode status = server.OnCopyConnector(username, request.Uri, destination, depth, overwrite, ifHeaders, out multiStatusValues);
                response.Status = status;
                if (status == (HttpStatusCode)207 && multiStatusValues != null) //multiple status
                {
                    byte[] bytes = XmlResponse.WriteMultiStatusResponseBody(multiStatusValues);
                    response.ContentLength = bytes.Length;
                    //Console.WriteLine(Encoding.UTF8.GetString(bytes));
                    response.Body.Write(bytes, 0, bytes.Length);
                }
            }
        }
开发者ID:jonnenauha,项目名称:ModreX,代码行数:60,代码来源:CopyCommand.cs

示例3: MkcolHandler

 void MkcolHandler(IHttpClientContext context, IHttpRequest request, IHttpResponse response)
 {
     string username;
     if (server.AuthenticateRequest(request, response, out username))
     {
         System.Net.HttpStatusCode status = server.CreateCollection(request.UriPath, username);
         response.Status = status;
     }
 }
开发者ID:jonnenauha,项目名称:ModreX,代码行数:9,代码来源:MkcolCommand.cs

示例4: HttpResponse

		/// <summary>
		/// Initializes a new instance of the <see cref="IHttpResponse"/> class.
		/// </summary>
		/// <param name="context">Client that send the <see cref="IHttpRequest"/>.</param>
		/// <param name="httpVersion">Version of HTTP protocol that the client uses.</param>
		/// <param name="connectionType">Type of HTTP connection used.</param>
		internal HttpResponse(IHttpClientContext context, string httpVersion, ConnectionType connectionType)
		{
			Check.NotEmpty(httpVersion, "httpVersion");

			Status = HttpStatusCode.OK;
			_context = context;
			_httpVersion = httpVersion;
			Connection = connectionType;
		}
开发者ID:Belxjander,项目名称:Asuna,代码行数:15,代码来源:HttpResponse.cs

示例5: PollServiceHttpRequest

 public PollServiceHttpRequest(PollServiceEventArgs pPollServiceArgs, IHttpClientContext pHttpContext,
                               IHttpRequest pRequest)
 {
     PollServiceArgs = pPollServiceArgs;
     HttpContext = pHttpContext;
     Request = pRequest;
     RequestTime = Environment.TickCount;
     RequestID = UUID.Random();
 }
开发者ID:savino1976,项目名称:Aurora-Sim,代码行数:9,代码来源:PollServiceHttpRequest.cs

示例6: TextureStatsHandler

 private void TextureStatsHandler(Capability cap, IHttpClientContext context, IHttpRequest request, IHttpResponse response)
 {
     try
     {
         OSD osd = OSDParser.Deserialize(request.Body);
         m_log.Info("Received a TextureStats message: " + osd.ToString());
     }
     catch (Exception)
     {
         m_log.Warn("Failed to decode TextureStats message");
     }
 }
开发者ID:thoys,项目名称:simian,代码行数:12,代码来源:ClientStats.cs

示例7: HttpResponse

    /// <summary>
    /// Initializes a new instance of the <see cref="IHttpResponse"/> class.
    /// </summary>
    /// <param name="context">Client that send the <see cref="IHttpRequest"/>.</param>
    /// <param name="request">Contains information of what the client want to receive.</param>
    /// <exception cref="ArgumentException"><see cref="IHttpRequest.HttpVersion"/> cannot be empty.</exception>
    public HttpResponse(IHttpClientContext context, IHttpRequest request)
    {
      Check.Require(context, "context");
      Check.Require(request, "request");

      _httpVersion = request.HttpVersion;
      if (string.IsNullOrEmpty(_httpVersion))
        throw new ArgumentException("HttpVersion in IHttpRequest cannot be empty.");

      Status = HttpStatusCode.OK;
      _context = context;
      Connection = request.Connection;
    }
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:19,代码来源:HttpResponse.cs

示例8: ParcelVoiceInfoRequestHandler

 private void ParcelVoiceInfoRequestHandler(Capability cap, IHttpClientContext context, IHttpRequest request, IHttpResponse response)
 {
     ParcelVoiceInfoRequestMessage message;
     if (LLUtil.TryGetMessage<ParcelVoiceInfoRequestMessage>(request.Body, out message))
     {
         m_log.DebugFormat("ParcelVoiceInfoRequest: RegionName={0}, ParcelID={1}, SipChannelUri={2}",
             message.RegionName, message.ParcelID, message.SipChannelUri);
     }
     else
     {
         m_log.Warn("Received invalid request data for ParcelVoiceInfoRequest");
         response.Status = System.Net.HttpStatusCode.BadRequest;
     }
 }
开发者ID:thoys,项目名称:simian,代码行数:14,代码来源:Voice.cs

示例9: DeleteHandler

 void DeleteHandler(IHttpClientContext context, IHttpRequest request, IHttpResponse response)
 {
     string username;
     if (server.AuthenticateRequest(request, response, out username))
     {
         Dictionary<string, HttpStatusCode> multiStatus = null;
         HttpStatusCode status = server.DeleteResource(request.Uri, username, out multiStatus);
         response.Status = status;
         if (status == (HttpStatusCode)207 && multiStatus != null) //multiple status
         {
             byte[] bytes = XmlResponse.WriteMultiStatusResponseBody(multiStatus);
             response.ContentLength = bytes.Length;
             //Console.WriteLine(Encoding.UTF8.GetString(bytes));
             response.Body.Write(bytes, 0, bytes.Length);
         }
     }
 }
开发者ID:jonnenauha,项目名称:ModreX,代码行数:17,代码来源:DeleteCommand.cs

示例10: OptionsHandler

        void OptionsHandler(IHttpClientContext context, IHttpRequest request, IHttpResponse response)
        {
            response.AddHeader("DAV", "2");
            response.AddHeader("MS-Author-Via", "DAV");

            //This now gets all the events that have handler from the dav listener
            string allowString = server.GetAvailableMethods();

            //Add this information to both, Public and Allow. We currently have no way of separating these two
            response.AddHeader("Public", allowString);
            response.AddHeader("Allow", allowString);

            //Preserving the old headers as reference. These should be removed when method is mature enough
            //response.AddHeader("Public", "COPY, DELETE, GET, HEAD, MKCOL, MOVE, OPTIONS, PROPFIND, PROPPATCH, PUT");
            //response.AddHeader("Allow", "COPY, DELETE, GET, HEAD, MKCOL, MOVE, OPTIONS, PROPFIND, PROPPATCH, PUT");

            server.HttpServer.LogWriter.Write(this, LogPrio.Debug, "Sending OPTIONS response for request to " + request.UriPath);
        }
开发者ID:jonnenauha,项目名称:ModreX,代码行数:18,代码来源:OptionsCommand.cs

示例11: UnlockHandler

 void UnlockHandler(IHttpClientContext context, IHttpRequest request, IHttpResponse response)
 {
     string username;
     if (server.AuthenticateRequest(request, response, out username))
     {
         string locktoken = (request.Headers.GetValues("Lock-Token"))[0];
         if (locktoken == null || locktoken == String.Empty)
         {
             response.Status = HttpStatusCode.BadRequest;
         }
         else
         {
             HttpStatusCode code = server.OnUnlockConnector(request.UriPath, locktoken, username);
             response.Status = code;
         }
     }
     else
     {
         response.Status = HttpStatusCode.Unauthorized;
     }
 }
开发者ID:jonnenauha,项目名称:ModreX,代码行数:21,代码来源:UnlockCommand.cs

示例12: HandleHTTPRequest

 /// <summary>
 /// Handles SUBSCRIBE and UNSUBSCRIBE HTTP requests.
 /// </summary>
 /// <param name="request">The HTTP request instance to handle</param>
 /// <param name="context">The HTTP client context of the specified <paramref name="request"/>.</param>
 /// <param name="config">The UPnP endpoint over that the HTTP request was received.</param>
 /// <returns><c>true</c> if the request could be handled and a HTTP response was sent, else <c>false</c>.</returns>
 public bool HandleHTTPRequest(IHttpRequest request, IHttpClientContext context, EndpointConfiguration config)
 {
   if (request.Method == "SUBSCRIBE")
   { // SUBSCRIBE events
     string pathAndQuery = request.Uri.PathAndQuery;
     DvService service;
     if (config.EventSubPathsToServices.TryGetValue(pathAndQuery, out service))
     {
       IHttpResponse response = request.CreateResponse(context);
       string httpVersion = request.HttpVersion;
       string userAgentStr = request.Headers.Get("USER-AGENT");
       string callbackURLsStr = request.Headers.Get("CALLBACK");
       string nt = request.Headers.Get("NT");
       string sid = request.Headers.Get("SID");
       string timeoutStr = request.Headers.Get("TIMEOUT");
       int timeout = UPnPConsts.GENA_DEFAULT_SUBSCRIPTION_TIMEOUT;
       ICollection<string> callbackURLs = null;
       if ((!string.IsNullOrEmpty(timeoutStr) && (!timeoutStr.StartsWith("Second-") ||
           !int.TryParse(timeoutStr.Substring("Second-".Length).Trim(), out timeout))) ||
           (!string.IsNullOrEmpty(callbackURLsStr) &&
           !TryParseCallbackURLs(callbackURLsStr, out callbackURLs)))
       {
         response.Status = HttpStatusCode.BadRequest;
         response.Send();
         return true;
       }
       if (!string.IsNullOrEmpty(sid) && (callbackURLs != null || !string.IsNullOrEmpty(nt)))
       {
         response.Status = HttpStatusCode.BadRequest;
         response.Reason = "Incompatible Header Fields";
         response.Send();
         return true;
       }
       if (callbackURLs != null && !string.IsNullOrEmpty(nt))
       { // Subscription
         bool subscriberSupportsUPnP11;
         try
         {
           if (string.IsNullOrEmpty(userAgentStr))
             subscriberSupportsUPnP11 = false;
           else
           {
             int minorVersion;
             if (!ParserHelper.ParseUserAgentUPnP1MinorVersion(userAgentStr, out minorVersion))
             {
               response.Status = HttpStatusCode.BadRequest;
               response.Send();
               return true;
             }
             subscriberSupportsUPnP11 = minorVersion >= 1;
           }
         }
         catch (Exception e)
         {
           UPnPConfiguration.LOGGER.Warn("GENAServerController: Error in event subscription", e);
           response.Status = HttpStatusCode.BadRequest;
           response.Send();
           return true;
         }
         if (service.HasComplexStateVariables && !subscriberSupportsUPnP11)
         {
           response.Status = HttpStatusCode.ServiceUnavailable;
           response.Send();
           return true;
         }
         bool validURLs = callbackURLs.All(url => url.StartsWith("http://"));
         if (nt != "upnp:event" || !validURLs)
         {
           response.Status = HttpStatusCode.PreconditionFailed;
           response.Reason = "Precondition Failed";
           response.Send();
           return true;
         }
         DateTime date;
         if (Subscribe(config, service, callbackURLs, httpVersion, subscriberSupportsUPnP11, ref timeout,
             out date, out sid))
         {
           response.Status = HttpStatusCode.OK;
           response.AddHeader("DATE", date.ToUniversalTime().ToString("R"));
           response.AddHeader("SERVER", UPnPConfiguration.UPnPMachineInfoHeader);
           response.AddHeader("SID", sid);
           response.AddHeader("CONTENT-LENGTH", "0");
           response.AddHeader("TIMEOUT", "Second-"+timeout);
           response.Send();
           SendInitialEventNotification(sid);
           return true;
         }
         response.Status = HttpStatusCode.ServiceUnavailable;
         response.Reason = "Unable to accept renewal"; // See (DevArch), table 4-4
         response.Send();
         return true;
       }
       if (!string.IsNullOrEmpty(sid))
//.........这里部分代码省略.........
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:101,代码来源:GENAServerController.cs

示例13: NewFileAgentInventoryVariablePriceUploadHandler

        private void NewFileAgentInventoryVariablePriceUploadHandler(NewFileAgentInventoryVariablePriceMessage message, Capability cap,
            IHttpClientContext context, IHttpRequest request, IHttpResponse response)
        {
            byte[] assetData = request.GetBody();
            UUID assetID = UUID.Zero;
            LLInventoryItem item = null;

            m_log.Debug("Received inventory asset upload from " + cap.OwnerID + " (" + assetData.Length + " bytes)");

            if (assetData != null && assetData.Length > 0)
            {
                string contentType = LLUtil.LLAssetTypeToContentType((int)message.AssetType);

                // Create the asset
                if (m_assetClient.StoreAsset(contentType, false, false, assetData, cap.OwnerID, out assetID))
                {
                    // Create the inventory item
                    item = new LLInventoryItem();
                    item.AssetID = assetID;
                    item.ContentType = contentType;
                    item.CreationDate = DateTime.UtcNow;
                    item.CreatorID = cap.OwnerID;
                    item.Description = message.Description;
                    item.ID = UUID.Random();
                    item.Name = message.Name;
                    item.OwnerID = cap.OwnerID;
                    item.ParentID = message.FolderID;

                    Permissions perms = (m_permissions != null) ? m_permissions.GetDefaultPermissions() : Permissions.FullPermissions;
                    perms.EveryoneMask = message.EveryoneMask;
                    perms.GroupMask = message.GroupMask;
                    perms.NextOwnerMask = message.NextOwnerMask;
                    item.Permissions = perms;

                    item.SalePrice = 10;
                    item.SaleType = SaleType.Not;

                    if (!m_inventoryClient.TryCreateItem(cap.OwnerID, item))
                        m_log.Warn("Failed to create inventory item for uploaded asset " + assetID);
                }
                else
                {
                    m_log.WarnFormat("Failed to store uploaded inventory asset ({0} bytes)", assetData.Length);
                }
            }
            else
            {
                m_log.Warn("Inventory asset upload contained no data");
            }

            // Build the response message
            NewFileAgentInventoryUploadReplyMessage reply = new NewFileAgentInventoryUploadReplyMessage();
            reply.NewAsset = assetID;
            if (item != null)
            {
                reply.NewInventoryItem = item.ID;
                reply.NewBaseMask = item.Permissions.BaseMask;
                reply.NewEveryoneMask = item.Permissions.EveryoneMask;
                reply.NewNextOwnerMask = item.Permissions.NextOwnerMask;
                reply.NewOwnerMask = item.Permissions.OwnerMask;
            }

            LLUtil.SendLLSDXMLResponse(response, reply.Serialize());
        }
开发者ID:thoys,项目名称:simian,代码行数:64,代码来源:NewFileAgentInventory.cs

示例14: NewFileAgentInventoryVariablePriceHandler

        private void NewFileAgentInventoryVariablePriceHandler(Capability cap, IHttpClientContext context, IHttpRequest request, IHttpResponse response)
        {
            NewFileAgentInventoryVariablePriceMessage message;
            if (LLUtil.TryGetMessage<NewFileAgentInventoryVariablePriceMessage>(request.Body, out message))
            {
                NewFileAgentInventoryVariablePriceReplyMessage reply = new NewFileAgentInventoryVariablePriceReplyMessage();
                reply.ResourceCost = 0;
                reply.UploadPrice = 0;

                // Create a one time upload capability
                reply.Rsvp = m_scene.Capabilities.AddOneTimeCapability(cap.OwnerID, true,
                    delegate(Capability _cap, IHttpClientContext _context, IHttpRequest _request, IHttpResponse _response)
                    { NewFileAgentInventoryVariablePriceUploadHandler(message, _cap, _context, _request, _response); }
                );

                LLUtil.SendLLSDXMLResponse(response, reply.Serialize());
            }
            else
            {
                m_log.Warn("Received invalid data for NewFileAgentInventoryVariablePrice");
                response.Status = System.Net.HttpStatusCode.BadRequest;
            }
        }
开发者ID:thoys,项目名称:simian,代码行数:23,代码来源:NewFileAgentInventory.cs

示例15: NewFileAgentInventoryUploadHandler

        private void NewFileAgentInventoryUploadHandler(NewFileAgentInventoryMessage message, Capability cap,
            IHttpClientContext context, IHttpRequest request, IHttpResponse response)
        {
            byte[] assetData = request.GetBody();
            UUID assetID = UUID.Zero;
            UUID itemID = UUID.Zero;

            m_log.Debug("Received inventory asset upload from " + cap.OwnerID + " (" + assetData.Length + " bytes)");

            if (assetData != null && assetData.Length > 0)
            {
                string contentType = LLUtil.LLAssetTypeToContentType((int)message.AssetType);

                // Create the asset
                if (m_assetClient.StoreAsset(contentType, false, false, assetData, cap.OwnerID, out assetID))
                {
                    // Create the inventory item
                    LLInventoryItem item = new LLInventoryItem();
                    item.AssetID = assetID;
                    item.ContentType = contentType;
                    item.CreationDate = DateTime.UtcNow;
                    item.CreatorID = cap.OwnerID;
                    item.Description = message.Description;
                    item.ID = UUID.Random();
                    item.Name = message.Name;
                    item.OwnerID = cap.OwnerID;
                    item.ParentID = message.FolderID;
                    item.Permissions = (m_permissions != null) ? m_permissions.GetDefaultPermissions() : Permissions.FullPermissions;
                    item.SalePrice = 10;
                    item.SaleType = SaleType.Not;

                    if (m_inventoryClient.TryCreateItem(cap.OwnerID, item))
                        itemID = item.ID;
                    else
                        m_log.Warn("Failed to create inventory item for uploaded asset " + assetID);
                }
                else
                {
                    m_log.WarnFormat("Failed to store uploaded inventory asset ({0} bytes)", assetData.Length);
                }
            }
            else
            {
                m_log.Warn("Inventory asset upload contained no data");
            }

            // Build the response message
            OSDMap reply = new OSDMap
            {
                { "state", OSD.FromString("complete") },
                { "new_asset", OSD.FromUUID(assetID) },
                { "new_inventory_item", OSD.FromUUID(itemID) }
            };

            LLUtil.SendLLSDXMLResponse(response, reply);
        }
开发者ID:thoys,项目名称:simian,代码行数:56,代码来源:NewFileAgentInventory.cs


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