Esempio n. 1
0
        public async Task <IHttpRequest> Provide(IStreamReader reader)
        {
            // parse the http request
            var request = await reader.ReadLine().ConfigureAwait(false);

            if (request == null)
            {
                return(null);
            }

            var firstSpace = request.IndexOf(' ');
            var lastSpace  = request.LastIndexOf(' ');

            var tokens = new []
            {
                request.Substring(0, firstSpace),
                request.Substring(firstSpace + 1, lastSpace - firstSpace - 1),
                request.Substring(lastSpace + 1)
            };

            if (tokens.Length != 3)
            {
                return(null);
            }


            var httpProtocol = tokens[2];

            var url         = tokens[1];
            var queryString = GetQueryStringData(ref url);
            var uri         = new Uri(url, UriKind.Relative);

            var headersRaw = new List <KeyValuePair <string, string> >();

            // get the headers
            string line;

            while (!string.IsNullOrEmpty((line = await reader.ReadLine().ConfigureAwait(false))))
            {
                string currentLine = line;

                var headerKvp = SplitHeader(currentLine);
                headersRaw.Add(headerKvp);
            }

            IHttpHeaders headers = new HttpHeaders(headersRaw.ToDictionary(k => k.Key, k => k.Value, StringComparer.InvariantCultureIgnoreCase));
            IHttpPost    post    = await GetPostData(reader, headers).ConfigureAwait(false);

            string verb;

            if (!headers.TryGetByName("_method", out verb))
            {
                verb = tokens[0];
            }
            var httpMethod = HttpMethodProvider.Default.Provide(verb);

            return(new HttpRequest(headers, httpMethod, httpProtocol, uri,
                                   uri.OriginalString.Split(Separators, StringSplitOptions.RemoveEmptyEntries), queryString, post));
        }
Esempio n. 2
0
 public HttpLongPollingTransport(
     IHttpPost httpPost,
     string url,
     Action <IEnumerable <JObject> > eventPublisher)
 {
     this.httpPost       = httpPost;
     this.url            = url;
     this.eventPublisher = eventPublisher;
 }
Esempio n. 3
0
 public HttpRequest(IHttpHeaders headers, HttpMethods method, string protocol, Uri uri, string[] requestParameters, IHttpHeaders queryString, IHttpPost post)
 {
     _headers           = headers;
     _method            = method;
     _protocol          = protocol;
     _uri               = uri;
     _requestParameters = requestParameters;
     _queryString       = queryString;
     _post              = post;
 }
Esempio n. 4
0
 public HttpRequest(IHttpHeaders headers, HttpMethods method, string protocol, Uri uri, string[] requestParameters, IHttpHeaders queryString, IHttpPost post)
 {
     Headers           = headers;
     Method            = method;
     Protocol          = protocol;
     Uri               = uri;
     RequestParameters = requestParameters;
     QueryString       = queryString;
     Post              = post;
 }
Esempio n. 5
0
 public VstsClient(
     IAppServiceSettings appServiceSettings,
     IHttpGet httpHelper,
     IHttpPost httpPost,
     ILog logger)
 {
     _appServiceSettings = appServiceSettings;
     _httpHelper         = httpHelper;
     _httpPost           = httpPost;
     _logger             = logger;
 }
 public BayeuxClient(
     IHttpPost httpPost,
     string url,
     IEnumerable <TimeSpan> reconnectDelays = null,
     TaskScheduler eventTaskScheduler       = null)
 {
     this.transport          = new HttpLongPollingTransport(httpPost, url, PublishEvents);
     this.eventTaskScheduler = ChooseEventTaskScheduler(eventTaskScheduler);
     this.connectLoop        = new ConnectLoop("long-polling", reconnectDelays, this);
     this.subscriber         = new Subscriber(this);
 }
Esempio n. 7
0
 public HttpRequest(IHttpHeaders headers, HttpMethods method, string protocol, Uri uri, string[] requestParameters, IHttpHeaders queryString, IHttpPost post)
 {
     _headers = headers;
     _method = method;
     _protocol = protocol;
     _uri = uri;
     _requestParameters = requestParameters;
     _queryString = queryString;
     _post = post;
 }
Esempio n. 8
0
 public AgentApiHttpPoster(IHttpPost innerPoster, String baseUrl)
 {
     this.innerPoster = innerPoster;
     this.baseUrl     = baseUrl;
 }