private HttpContractedClient(Type contractType, HttpContractedClientOptions options) { this.ContractType = contractType; this.Channel = options.Channel; this.RequestSpecifier = options.RequestSpecifier; this.BaseAddress = Channel.BaseAddress; }
public HttpResponseImpl(IHttpChannel channel) { if (channel == null) throw new ArgumentNullException("channel"); _channel = channel; _body = new MemoryStream(); _output = new StreamWriter(_body); }
public HttpResponseImpl(IHttpChannel channel) { if (channel == null) { throw new ArgumentNullException("channel"); } _channel = channel; _body = new MemoryStream(); _output = new StreamWriter(_body); }
public Client( IHttpChannel httpClient, string domainName, string userName, string password ) { HttpClient = httpClient; DomainName = domainName; UserName = userName; Password = password; }
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); }
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); }
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)); }
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)); }
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); }
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; }
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; }
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()); } } }
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); }
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); }
public HttpContractedClientOptions(IHttpRequestSpecifier RequestSpecifier, IHttpChannel Channel) { this.RequestSpecifier = RequestSpecifier; this.Channel = Channel; }
public HttpContextImpl(IHttpChannel channel, HttpServerSettings settings) { ServerSettings = settings; _request = new HttpRequestImpl(this, channel, settings); _response = new HttpResponseImpl(channel); }
public IZendeskClient Create(Uri baseUri, ZendeskDefaultConfiguration configuration, ISerializer serializer = null, IHttpChannel httpChannel = null, ILogAdapter logger = null) { return new ZendeskClient(baseUri, configuration, serializer, httpChannel, logger); }
public NasdaqQuoteProvider(IHttpChannel client) { _client = client; }
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);
public HttpContextImpl(IHttpChannel channel, HttpServerSettings settings) { _request = new HttpRequestImpl(this, channel, settings); _response = new HttpResponseImpl(channel); }
public IZendeskClient Create(Uri baseUri, ZendeskDefaultConfiguration configuration, ISerializer serializer = null, IHttpChannel httpChannel = null, ILogAdapter logger = null) { return(new ZendeskClient(baseUri, configuration, serializer, httpChannel, logger)); }