コード例 #1
0
ファイル: WebRequest.cs プロジェクト: nlhepler/mono
        public static System.Data.Services.Http.WebRequest Create(Uri requestUri, HttpStack httpStack)
        {
            Debug.Assert(requestUri != null, "requestUri != null");
            if ((requestUri.Scheme != Uri.UriSchemeHttp) && (requestUri.Scheme != Uri.UriSchemeHttps))
            {
                throw new NotSupportedException();
            }

            if (httpStack == HttpStack.Auto)
            {
                if (UriRequiresClientHttpWebRequest(requestUri))
                {
                    httpStack = HttpStack.ClientHttp;
                }
                else
                {
                    httpStack = HttpStack.XmlHttp;
                }
            }

            if (httpStack == HttpStack.ClientHttp)
            {
                return new ClientHttpWebRequest(requestUri);
            }
            else
            {
                Debug.Assert(httpStack == HttpStack.XmlHttp, "Only ClientHttp and XmlHttp are supported for now.");
                return new XHRHttpWebRequest(requestUri);
            }
        }
コード例 #2
0
        public static Microsoft.OData.Service.Http.WebRequest Create(Uri requestUri, HttpStack httpStack)
        {
            Debug.Assert(requestUri != null, "requestUri != null");
            if ((requestUri.Scheme != PlatformHelper.UriSchemeHttp) && (requestUri.Scheme != PlatformHelper.UriSchemeHttps))
            {
                // "SR.GetString(SR.net_unknown_prefix)"
                throw new NotSupportedException();
            }

#if !WINDOWS_PHONE && !PORTABLELIB
            if (httpStack == HttpStack.Auto)
            {
                if (UriRequiresClientHttpWebRequest(requestUri))
                {
                    httpStack = HttpStack.ClientHttp;
                }
                else
                {
                    httpStack = HttpStack.XmlHttp;
                }
            }

            if (httpStack == HttpStack.ClientHttp)
            {
                return(new ClientHttpWebRequest(requestUri));
            }
            else
            {
                Debug.Assert(httpStack == HttpStack.XmlHttp, "Only ClientHttp and XmlHttp are supported for now.");
                return(new XHRHttpWebRequest(requestUri));
            }
#else
            return(new ClientHttpWebRequest(requestUri));
#endif
        }
コード例 #3
0
        public static System.Data.Services.Http.WebRequest Create(Uri requestUri, HttpStack httpStack)
        {
            Debug.Assert(requestUri != null, "requestUri != null");
            if ((requestUri.Scheme != Uri.UriSchemeHttp) && (requestUri.Scheme != Uri.UriSchemeHttps))
            {
                throw new NotSupportedException();
            }

            if (httpStack == HttpStack.Auto)
            {
                if (UriRequiresClientHttpWebRequest(requestUri))
                {
                    httpStack = HttpStack.ClientHttp;
                }
                else
                {
                    httpStack = HttpStack.XmlHttp;
                }
            }

            if (httpStack == HttpStack.ClientHttp)
            {
                return(new ClientHttpWebRequest(requestUri));
            }
            else
            {
                Debug.Assert(httpStack == HttpStack.XmlHttp, "Only ClientHttp and XmlHttp are supported for now.");
                return(new XHRHttpWebRequest(requestUri));
            }
        }
コード例 #4
0
            public ProxyCommunicator(ICoapConfig config)
            {
                _coapStack = new CoapStack(config);
                _httpStack = new HttpStack(config.HttpPort);

                _coapStack.RegisterReceiver(this);
                _httpStack.RegisterReceiver(this);
            }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BuildingRequestEventArgs"/> class.
 /// </summary>
 /// <param name="method">The method.</param>
 /// <param name="requestUri">The request URI.</param>
 /// <param name="headers">The request headers.</param>
 /// <param name="descriptor">Descriptor for this request; or null if there isn't one.</param>
 /// <param name="httpStack">The http stack.</param>
 internal BuildingRequestEventArgs(string method, Uri requestUri, HeaderCollection headers, Descriptor descriptor, HttpStack httpStack)
 {
     this.Method = method;
     this.RequestUri = requestUri;
     this.HeaderCollection = headers ?? new HeaderCollection();
     this.ClientHttpStack = httpStack;
     this.Descriptor = descriptor;
 }
コード例 #6
0
        public static Microsoft.WindowsAzure.Samples.Data.Services.Client.WebRequest Create(Uri requestUri, HttpStack httpStack)
        {
            Debug.Assert(requestUri != null, "requestUri != null");
            if ((requestUri.Scheme != Uri.UriSchemeHttp) && (requestUri.Scheme != Uri.UriSchemeHttps))
            {
                throw new NotSupportedException();
            }

            return new ClientHttpWebRequest(requestUri);
        }
コード例 #7
0
        /// <summary>
        /// Validate HttpStack
        /// </summary>
        /// <param name="value">option to validate</param>
        /// <param name="parameterName">name of the parameter being validated</param>
        /// <exception cref="System.ArgumentOutOfRangeException">if option is not valid</exception>
        /// <returns>option</returns>
        internal static HttpStack CheckEnumerationValue(HttpStack value, string parameterName)
        {
            switch (value)
            {
            case HttpStack.Auto:
                return(value);

            default:
                throw Error.ArgumentOutOfRange(parameterName);
            }
        }
コード例 #8
0
ファイル: Util.cs プロジェクト: zdzislaw/odata.net
        /// <summary>
        /// Validate HttpStack
        /// </summary>
        /// <param name="value">option to validate</param>
        /// <param name="parameterName">name of the parameter being validated</param>
        /// <exception cref="System.ArgumentOutOfRangeException">if option is not valid</exception>
        /// <returns>option</returns>
        internal static HttpStack CheckEnumerationValue(HttpStack value, string parameterName)
        {
            switch (value)
            {
            case HttpStack.Auto:
#if ASTORIA_LIGHT
            case HttpStack.ClientHttp:
            case HttpStack.XmlHttp:
#endif
                return(value);

            default:
                throw Error.ArgumentOutOfRange(parameterName);
            }
        }
コード例 #9
0
ファイル: WebRequest.cs プロジェクト: npenin/uss
 public static WebRequest Create(Uri requestUri, HttpStack httpStack)
 {
     if ((requestUri.Scheme != Uri.UriSchemeHttp) && (requestUri.Scheme != Uri.UriSchemeHttps))
     {
         throw new NotSupportedException();
     }
     if (httpStack == HttpStack.Auto)
     {
         if (UriRequiresClientHttpWebRequest(requestUri))
         {
             httpStack = HttpStack.ClientHttp;
         }
         else
         {
             httpStack = HttpStack.XmlHttp;
         }
     }
     if (httpStack == HttpStack.ClientHttp)
     {
         return new ClientHttpWebRequest(requestUri);
     }
     return new XHRHttpWebRequest(requestUri);
 }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BuildingRequestEventArgs"/> class.
 /// </summary>
 /// <param name="method">The method.</param>
 /// <param name="requestUri">The request URI.</param>
 /// <param name="headers">The request headers.</param>
 /// <param name="descriptor">Descriptor for this request; or null if there isn't one.</param>
 /// <param name="httpStack">The http stack.</param>
 internal BuildingRequestEventArgs(string method, Uri requestUri, HeaderCollection headers, Descriptor descriptor, HttpStack httpStack)
 {
     this.Method           = method;
     this.RequestUri       = requestUri;
     this.HeaderCollection = headers ?? new HeaderCollection();
     this.ClientHttpStack  = httpStack;
     this.Descriptor       = descriptor;
 }
コード例 #11
0
 /// <summary>
 /// Returns the request message to write the headers and payload into.
 /// </summary>
 /// <param name="method">Http method for the request.</param>
 /// <param name="requestUri">Base Uri for the request.</param>
 /// <param name="headers">Request headers.</param>
 /// <param name="httpStack">HttpStack to use.</param>
 /// <param name="descriptor">Descriptor for the request, if there is one.</param>
 /// <param name="contentId">Content-ID header that could be used in batch request.</param>
 /// <returns>an instance of IODataRequestMessage.</returns>
 protected override ODataRequestMessageWrapper CreateRequestMessage(string method, Uri requestUri, HeaderCollection headers, HttpStack httpStack, Descriptor descriptor, string contentId)
 {
     BuildingRequestEventArgs args = this.RequestInfo.CreateRequestArgsAndFireBuildingRequest(method, requestUri, headers, this.RequestInfo.HttpStack, descriptor);
     return ODataRequestMessageWrapper.CreateBatchPartRequestMessage(this.batchWriter, args, this.RequestInfo, contentId);
 }
コード例 #12
0
 public DataServiceClientRequestMessageArgs(string method, Uri requestUri, bool usePostTunneling, bool useDefaultCredentials, IDictionary <string, string> headers, HttpStack httpStack)
     : this(method, requestUri, usePostTunneling, useDefaultCredentials, headers)
 {
     this.ClientHttpStack = httpStack;
 }
コード例 #13
0
 /// <summary>
 /// Asks the context to Fire the BuildingRequest event and get RequestMessageArgs.
 /// </summary>
 /// <param name="method">Http method for the request.</param>
 /// <param name="requestUri">Base Uri for the request.</param>
 /// <param name="headers">Request headers.</param>
 /// <param name="httpStack">HttpStack to use.</param>
 /// <param name="descriptor">Descriptor for the request, if there is one.</param>
 /// <returns>A new RequestMessageArgs object for building the request message.</returns>
 internal BuildingRequestEventArgs CreateRequestArgsAndFireBuildingRequest(string method, Uri requestUri, HeaderCollection headers, HttpStack httpStack, Descriptor descriptor)
 {
     return(this.Context.CreateRequestArgsAndFireBuildingRequest(method, requestUri, headers, httpStack, descriptor));
 }
コード例 #14
0
ファイル: RequestInfo.cs プロジェクト: AlineGuan/odata.net
 /// <summary>
 /// Asks the context to Fire the BuildingRequest event and get RequestMessageArgs.
 /// </summary>
 /// <param name="method">Http method for the request.</param>
 /// <param name="requestUri">Base Uri for the request.</param>
 /// <param name="headers">Request headers.</param>
 /// <param name="httpStack">HttpStack to use.</param>
 /// <param name="descriptor">Descriptor for the request, if there is one.</param>
 /// <returns>A new RequestMessageArgs object for building the request message.</returns>
 internal BuildingRequestEventArgs CreateRequestArgsAndFireBuildingRequest(string method, Uri requestUri, HeaderCollection headers, HttpStack httpStack, Descriptor descriptor)
 {
     return this.Context.CreateRequestArgsAndFireBuildingRequest(method, requestUri, headers, httpStack, descriptor);
 }
コード例 #15
0
ファイル: BaseSaveResult.cs プロジェクト: larsenjo/odata.net
 /// <summary>
 /// Returns the request message to write the headers and payload into.
 /// </summary>
 /// <param name="method">Http method for the request.</param>
 /// <param name="requestUri">Base Uri for the request.</param>
 /// <param name="headers">Request headers.</param>
 /// <param name="httpStack">HttpStack to use.</param>
 /// <param name="descriptor">Descriptor for the request, if there is one.</param>
 /// <returns>an instance of IODataRequestMessage.</returns>
 protected ODataRequestMessageWrapper CreateTopLevelRequest(string method, Uri requestUri, HeaderCollection headers, HttpStack httpStack, Descriptor descriptor)
 {
     BuildingRequestEventArgs args = this.RequestInfo.CreateRequestArgsAndFireBuildingRequest(method, requestUri, headers, httpStack, descriptor);
     return this.RequestInfo.WriteHelper.CreateRequestMessage(args);
 }
コード例 #16
0
ファイル: BaseSaveResult.cs プロジェクト: larsenjo/odata.net
 /// <summary>
 /// Returns the request message to write the headers and payload into.
 /// </summary>
 /// <param name="method">Http method for the request.</param>
 /// <param name="requestUri">Base Uri for the request.</param>
 /// <param name="headers">Request headers.</param>
 /// <param name="httpStack">HttpStack to use.</param>
 /// <param name="descriptor">Descriptor for the request, if there is one.</param>
 /// <param name="contentId">Content-ID header that could be used in batch request.</param>
 /// <returns>an instance of IODataRequestMessage.</returns>
 protected abstract ODataRequestMessageWrapper CreateRequestMessage(string method, Uri requestUri, HeaderCollection headers, HttpStack httpStack, Descriptor descriptor, string contentId);
コード例 #17
0
ファイル: SaveResult.cs プロジェクト: larsenjo/odata.net
 /// <summary>
 /// Returns the request message to write the headers and payload into.
 /// </summary>
 /// <param name="method">Http method for the request.</param>
 /// <param name="requestUri">Base Uri for the request.</param>
 /// <param name="headers">Request headers.</param>
 /// <param name="httpStack">HttpStack to use.</param>
 /// <param name="descriptor">Descriptor for the request, if there is one.</param>
 /// <param name="contentId">Content-ID header that could be used in batch request.</param>
 /// <returns>an instance of IODataRequestMessage.</returns>
 protected override ODataRequestMessageWrapper CreateRequestMessage(string method, Uri requestUri, HeaderCollection headers, HttpStack httpStack, Descriptor descriptor, string contentId)
 {
     return this.CreateTopLevelRequest(method, requestUri, headers, httpStack, descriptor);
 }
コード例 #18
0
ファイル: SaveResult.cs プロジェクト: pbvs/odata.net
 /// <summary>
 /// Returns the request message to write the headers and payload into.
 /// </summary>
 /// <param name="method">Http method for the request.</param>
 /// <param name="requestUri">Base Uri for the request.</param>
 /// <param name="headers">Request headers.</param>
 /// <param name="httpStack">HttpStack to use.</param>
 /// <param name="descriptor">Descriptor for the request, if there is one.</param>
 /// <param name="contentId">Content-ID header that could be used in batch request.</param>
 /// <returns>an instance of IODataRequestMessage.</returns>
 protected override ODataRequestMessageWrapper CreateRequestMessage(string method, Uri requestUri, HeaderCollection headers, HttpStack httpStack, Descriptor descriptor, string contentId)
 {
     return(this.CreateTopLevelRequest(method, requestUri, headers, httpStack, descriptor));
 }
コード例 #19
0
        /// <summary>
        /// Returns the request message to write the headers and payload into.
        /// </summary>
        /// <param name="method">Http method for the request.</param>
        /// <param name="requestUri">Base Uri for the request.</param>
        /// <param name="headers">Request headers.</param>
        /// <param name="httpStack">HttpStack to use.</param>
        /// <param name="descriptor">Descriptor for the request, if there is one.</param>
        /// <param name="contentId">Content-ID header that could be used in batch request.</param>
        /// <returns>an instance of IODataRequestMessage.</returns>
        protected override ODataRequestMessageWrapper CreateRequestMessage(string method, Uri requestUri, HeaderCollection headers, HttpStack httpStack, Descriptor descriptor, string contentId)
        {
            BuildingRequestEventArgs args = this.RequestInfo.CreateRequestArgsAndFireBuildingRequest(method, requestUri, headers, this.RequestInfo.HttpStack, descriptor);

            return(ODataRequestMessageWrapper.CreateBatchPartRequestMessage(this.batchWriter, args, this.RequestInfo, contentId));
        }
コード例 #20
0
 /// <summary>
 /// Creates an instance of DataServiceTransportInfo.
 /// </summary>
 /// <param name="context">DataServiceContext instance.</param>
 /// <param name="httpStack">HttpStack to use for silverlight.</param>
 internal DataServiceTransportInfo(DataServiceContext context, HttpStack httpStack)
 {
     Debug.Assert(context != null, "context != null");
     this.Context   = context;
     this.HttpStack = httpStack;
 }