Ejemplo n.º 1
0
        private static HttpRequestMessage GetHttpRequest(QQHttpRequest qqRequest)
        {
            var request = new HttpRequestMessage(new HttpMethod(qqRequest.Method), qqRequest.Url)
            {
                Headers =
                {
                    Referrer = new Uri(qqRequest.Referrer),
                    //UserAgent =
                    //{
                    //    new ProductInfoHeaderValue(qqRequest.UserAgent)
                    //},
                }
            };

            if (qqRequest.Method.Equals(HttpConstants.Post))
            {
                request.Content = new StringContent(qqRequest.GetPostString(), Encoding.GetEncoding(qqRequest.Charset), qqRequest.ContentType);
            }
            else if (qqRequest.Method.Equals(HttpConstants.Get))
            {
            }
            else
            {
                throw new QQException(QQErrorCode.IOError, "not support http method:" + request.Method);
            }
            return(request);
        }