コード例 #1
0
 private HttpContractedClient(Type contractType, HttpContractedClientOptions options)
 {
     this.ContractType     = contractType;
     this.Channel          = options.Channel;
     this.RequestSpecifier = options.RequestSpecifier;
     this.BaseAddress      = Channel.BaseAddress;
 }
コード例 #2
0
        public HttpResponseImpl(IHttpChannel channel)
        {
            if (channel == null) throw new ArgumentNullException("channel");

            _channel = channel;
            _body = new MemoryStream();
            _output = new StreamWriter(_body);
        }
コード例 #3
0
        public HttpResponseImpl(IHttpChannel channel)
        {
            if (channel == null)
            {
                throw new ArgumentNullException("channel");
            }

            _channel = channel;
            _body    = new MemoryStream();
            _output  = new StreamWriter(_body);
        }
コード例 #4
0
ファイル: Client.cs プロジェクト: bjorncoltof/NfieldSDK
 public Client(
     IHttpChannel httpClient,
     string domainName,
     string userName,
     string password
     )
 {
     HttpClient = httpClient;
     DomainName = domainName;
     UserName = userName;
     Password = password;
 }
コード例 #5
0
 public ZendeskClient(Uri baseUri, ZendeskDefaultConfiguration configuration, ISerializer serializer = null, IHttpChannel httpChannel = null, ILogAdapter logger = null)
     :base(baseUri, configuration, serializer, httpChannel, logger)
 {
     Tickets = new TicketResource(this);
     TicketComments = new TicketCommentResource(this);
     Organizations = new OrganizationResource(this);
     Search = new SearchResource(this);
     Groups = new GroupsResource(this);
     AssignableGroups = new AssignableGroupResource(this);
     Users = new UserResource(this);
     UserIdentities = new UserIdentityResource(this);
     OrganizationMemberships = new OrganizationMembershipResource(this);
 }
コード例 #6
0
        public static string DownloadToString(this IHttpChannel channel, string url, Encoding?encoding = default, AuthenticationHeaderValue?authenticationHeaderValue = null)
        {
            encoding = encoding ?? Encoding.UTF8;
            var request = channel.CreateRequest(url);

            if (authenticationHeaderValue != null)
            {
                request.Headers.Authorization = authenticationHeaderValue;
            }
            var result          = SharedHttpClient.Value.SendAsync(request).Result;
            var contentAsString = result.Content.ReadAsStringAsync().Result;

            return(contentAsString);
        }
コード例 #7
0
        protected ClientBase(Uri baseUri, ZendeskDefaultConfiguration configuration, ISerializer serializer = null, IHttpChannel httpChannel = null, ILogAdapter loggerAdapter = null)
        {
            if (baseUri == null)
            {
                throw new ArgumentNullException("baseUri");
            }
            var logger = loggerAdapter ?? new Logging.SystemDiagnosticsAdapter();

            _baseUri       = baseUri;
            _configuration = configuration;
            _http          = httpChannel ?? new HttpChannel();
            _serializer    = serializer ?? new Serialization.ZendeskJsonSerializer();
            logger.Debug(string.Format("Created Zendesk client. BaseUri: {0}, Serializer: {1}, HttpChannel: {2}, Logger: {3}",
                                       _baseUri, _serializer.GetType().Name, _http.GetType().Name, logger.GetType().Name));
        }
コード例 #8
0
        public static IHttpHeader DownloadHeader(this IHttpChannel channel, string url, AuthenticationHeaderValue?authenticationHeaderValue = null)
        {
            var request = channel.CreateRequest(url);

            if (authenticationHeaderValue != null)
            {
                request.Headers.Authorization = authenticationHeaderValue;
            }

            request.Method = HttpMethod.Head;

            var result = SharedHttpClient.Value.SendAsync(request).Result;

            var dict = result.Headers.ToDictionary(key => key.Key, v => v.Value.ToString() ?? "");

            return(new HttpHeader(dict));
        }
コード例 #9
0
        public HttpRequestImpl(HttpContextImpl context, IHttpChannel channel, HttpServerSettings settings)
        {
            _context = context;

            Method = channel.Method;

            var path = channel.Path;
            if (!path.StartsWith("/")) path = "/" + path;
            Uri = new Uri(string.Format("http://localhost:{0}{1}", settings.Port, path));

            _headers.AddRange(
                from key in channel.Headers.AllKeys
                select new KeyValuePair<string, string>(key, channel.Headers[key])
                );

            var len = _headers.GetContentLength();
            Body = len > 0 ? channel.Body : new MemoryStream(new byte[0], false);
        }
コード例 #10
0
        public BuildMonitor(BuildMonitorConfiguration configuration, IHttpChannel httpChannel,
                            BuildSucceeded buildSuccessfulCallback,
                            BuildFailed buildFailedCallback,
                            FailedToEvaluateBuildStatus failedToEvaluateBuildStatus)
        {
            if (configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (httpChannel == null)
            {
                throw new ArgumentNullException("httpChannel");
            }

            _configuration               = configuration;
            _httpChannel                 = httpChannel;
            _buildSuccessfulCallback     = buildSuccessfulCallback;
            _buildFailedCallback         = buildFailedCallback;
            _failedToEvaluateBuildStatus = failedToEvaluateBuildStatus;
        }
コード例 #11
0
        public BuildMonitor(BuildMonitorConfiguration configuration, IHttpChannel httpChannel,
                                                                     BuildSucceeded buildSuccessfulCallback, 
                                                                     BuildFailed buildFailedCallback, 
                                                                     FailedToEvaluateBuildStatus failedToEvaluateBuildStatus)
        {
            if(configuration == null)
            {
                throw new ArgumentNullException("configuration");
            }

            if (httpChannel == null)
            {
                throw new ArgumentNullException("httpChannel");
            }

            _configuration = configuration;
            _httpChannel = httpChannel;
            _buildSuccessfulCallback = buildSuccessfulCallback;
            _buildFailedCallback = buildFailedCallback;
            _failedToEvaluateBuildStatus = failedToEvaluateBuildStatus;
        }
コード例 #12
0
        public static void ProcessRequest(this IHttpChannel channel, IHttpHandler handler, HttpServerSettings settings)
        {
            var context = new HttpContextImpl(channel, settings);
            var res     = context.Response;

            using (res.OutputStream)
            {
                try
                {
                    var app = handler as ExpressApplication;
                    if (app != null)
                    {
                        if (!app.Process(context))
                        {
                            res.StatusCode        = (int)HttpStatusCode.NotFound;
                            res.StatusDescription = "Not found";
                            res.ContentType       = "text/plain";
                            res.Write("Resource not found!");
                        }

                        res.Flush();
                        res.End();
                    }
                    else
                    {
                        var workerRequest = new HttpWorkerRequestImpl(context, settings);
                        handler.ProcessRequest(new HttpContext(workerRequest));
                        workerRequest.EndOfRequest();
                    }
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine(e);

                    res.StatusCode  = (int)HttpStatusCode.InternalServerError;
                    res.ContentType = "text/plain";
                    res.Write(e.ToString());
                }
            }
        }
コード例 #13
0
        public HttpRequestImpl(HttpContextImpl context, IHttpChannel channel, HttpServerSettings settings)
        {
            _context = context;

            Method = channel.Method;

            var path = channel.Path;

            if (!path.StartsWith("/"))
            {
                path = "/" + path;
            }
            Uri = new Uri(string.Format("http://localhost:{0}{1}", settings.Port, path));

            _headers.AddRange(
                from key in channel.Headers.AllKeys
                select new KeyValuePair <string, string>(key, channel.Headers[key])
                );

            var len = _headers.GetContentLength();

            Body = len > 0 ? channel.Body : new MemoryStream(new byte[0], false);
        }
コード例 #14
0
 public ZendeskClient(
     Uri baseUri,
     ZendeskDefaultConfiguration configuration,
     ISerializer serializer   = null,
     IHttpChannel httpChannel = null,
     ILogAdapter logger       = null)
     : base(baseUri, configuration, serializer, httpChannel, logger)
 {
     Tickets                 = new TicketResource(this);
     TicketComments          = new TicketCommentResource(this);
     RequestComments         = new RequestCommentResource(this);
     Organizations           = new OrganizationResource(this);
     Search                  = new SearchResource(this);
     Groups                  = new GroupsResource(this);
     AssignableGroups        = new AssignableGroupResource(this);
     Users                   = new UserResource(this);
     UserIdentities          = new UserIdentityResource(this);
     Upload                  = new UploadResource(this);
     TicketFields            = new TicketFieldResource(this);
     TicketForms             = new TicketFormResource(this);
     OrganizationMemberships = new OrganizationMembershipResource(this);
     Request                 = new RequestResource(this);
     SatisfactionRating      = new SatisfactionRatingResource(this);
 }
コード例 #15
0
 public HttpContractedClientOptions(IHttpRequestSpecifier RequestSpecifier, IHttpChannel Channel)
 {
     this.RequestSpecifier = RequestSpecifier;
     this.Channel          = Channel;
 }
コード例 #16
0
 public HttpContextImpl(IHttpChannel channel, HttpServerSettings settings)
 {
     ServerSettings = settings;
     _request = new HttpRequestImpl(this, channel, settings);
     _response = new HttpResponseImpl(channel);
 }
コード例 #17
0
 public IZendeskClient Create(Uri baseUri, ZendeskDefaultConfiguration configuration, ISerializer serializer = null, IHttpChannel httpChannel = null, ILogAdapter logger = null)
 {
     return new ZendeskClient(baseUri, configuration, serializer, httpChannel, logger);
 }
コード例 #18
0
 public NasdaqQuoteProvider(IHttpChannel client)
 {
     _client = client;
 }
コード例 #19
0
 public static bool TryDownloadHeader(this IHttpChannel channel, string url, out IHttpHeader header)
 {
     header = new HttpHeader("plain", 0);
     var success = new Tryify <IHttpHeader?>()
                   .TryInvoke(() => channel.DownloadHeader(url), out var result, fallback: default);
コード例 #20
0
 public HttpContextImpl(IHttpChannel channel, HttpServerSettings settings)
 {
     _request  = new HttpRequestImpl(this, channel, settings);
     _response = new HttpResponseImpl(channel);
 }
コード例 #21
0
 public IZendeskClient Create(Uri baseUri, ZendeskDefaultConfiguration configuration, ISerializer serializer = null, IHttpChannel httpChannel = null, ILogAdapter logger = null)
 {
     return(new ZendeskClient(baseUri, configuration, serializer, httpChannel, logger));
 }