public ZendeskDefaultConfiguration(string username, string token) { Headers = new Headers(); var auth = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}/token:{1}", username, token))); Headers.AddHeader(AcceptCharset, "utf-8"); Headers.AddHeader(Authorization, string.Format("Basic {0}", auth)); Headers.AddHeader(AcceptKey, "application/json"); Headers.AddHeader(ContentTypeKey, "application/json"); }
public HtmlResult(string content, HttpResponseStatusCode responseStatusCode) : base(responseStatusCode) { Content = Encoding.UTF8.GetBytes(content); Headers.AddHeader(new HttpHeader(Constants.ContentTypeHeaderKey, Constants.HtmlContentTypeHeaderValue)); Headers.AddHeader(new HttpHeader(Constants.ContentLengthHeaderKey, Content.Length.ToString())); }
private void ParseHeaders(string[] rawHeaders) { foreach (var rawHeader in rawHeaders) { string[] parts = rawHeader.Split(HttpHeaderNameValueSeparator, 2); if (parts[0] == HttpHeader.Cookie) { ParseCookies(parts[1]); continue; } if (parts.Length == 1 && parts[0] == string.Empty) { break; } Headers.AddHeader(new HttpHeader(parts[0], parts[1])); } if (!Headers.ContainsHeader(HttpHeader.Host)) { throw new BadRequestException(); } }
public InlineResourceResult(byte[] content, HttpResponseStatusCode httpResponseStatusCode) : base(httpResponseStatusCode) { Headers.AddHeader(new HttpHeader(HttpHeader.ContentLength, content.Length.ToString())); Headers.AddHeader(new HttpHeader(HttpHeader.ContentDisposition, "inline")); Content = content; }
private void ParseHeaders(string[] requestLines) { bool isHostHeaderPresent = false; foreach (var currentLine in requestLines) { if (string.IsNullOrEmpty(currentLine)) { break; } string[] currentLineArray = currentLine.Split(": "); string header = currentLineArray[0]; string headerData = currentLineArray[1]; HttpHeader httpHeader = new HttpHeader(header, headerData); Headers.AddHeader(httpHeader); if (header == "Host") { isHostHeaderPresent = true; } } if (isHostHeaderPresent == false) { throw new BadRequestException(); } }
public void TestBuildHeaders() { var headers = new Headers(); headers.AddHeader(HeaderNames.Created, "2004-09-21T03:01:52Z"); headers.ShouldBe(Resource.Get("Xmpp.Shim.headers1.xml")); }
public void AddHeaderTakesInANameAndValueAndReturnsANewHeadersWithTheAdditionalHeader() { var testHeaders = new Headers("test", "header"); var updatedHeaders = testHeaders.AddHeader("additional", "header"); var addedHeader = updatedHeaders["additional"]; Assert.Equal("additional", addedHeader.Name); Assert.Equal("header", addedHeader.Value); }
public void AddHeaderTakesInANameAndValueAndReplacesTheExistingHeaderWhenANamingConflictOccurs() { var testHeaders = new Headers("test", "header"); var updatedHeaders = testHeaders.AddHeader("test", "NewValue"); var changedHeader = updatedHeaders["test"]; Assert.Equal("test", changedHeader.Name); Assert.Equal("NewValue", changedHeader.Value); }
public void TestHeaders2() { var headers = new Headers(); headers.AddHeader(HeaderNames.Created, "2004-09-21T03:01:52Z"); headers.ShouldBe(Resource.Get("Xmpp.Shim.headers1.xml")); var headers2 = new Headers(); headers2[HeaderNames.Created].Value = "2004-09-21T03:01:52Z"; headers2.ShouldBe(Resource.Get("Xmpp.Shim.headers1.xml")); }
internal Shim() { /* * Example of an Urgent Message * * <message * from='[email protected]/orchard' * to='*****@*****.**' * type='chat'> * <body>Wherefore are thou?!?</body> * <headers xmlns='http://jabber.org/protocol/shim'> * <header name='Urgency'>high</header> * </headers> * </message> */ // Create the message aboute which includes the shim header urgency agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message(); msg.From = new Jid("[email protected]/orchard"); msg.To = new Jid("*****@*****.**"); msg.Type = MessageType.chat; msg.Body = "Wherefore are thou?!?"; Headers headers = new Headers(); headers.AddHeader("Urgency", "high"); msg.Headers = headers; // or // msg.AddChild(headers); Program.Print(msg); // after we created this header we want to change the urgency of the existing message to low Headers heads = msg.Headers; if (heads != null) { heads.SetHeader("Urgency", "low"); } Program.Print(msg); // Add another header // <header name='In-Reply-To'>[email protected]</header> msg.Headers.AddHeader("In-Reply-To", "*****@*****.**"); Program.Print(msg); // Remove all Headers msg.Headers = null; Program.Print(msg); }
private void ParseHeaders(string[] requestHeaders) { foreach (var requestHeader in requestHeaders) { string[] headerArgs = requestHeader.Split(": ", StringSplitOptions.RemoveEmptyEntries); if (headerArgs.Length == 2 && headerArgs[0] != Constants.CookieRequestHeaderKey) { string headerKey = headerArgs[0]; string headerValue = headerArgs[1]; IHttpHeader header = new HttpHeader(headerKey, headerValue); Headers.AddHeader(header); } } if (Headers.GetHeader(Constants.HostHeaderKey) == null) throw new BadRequestException(); }
private static Headers GetRequestHeaders(string requestString) { var headers = new Headers(); var requestLines = requestString.Split("\r\n", StringSplitOptions.RemoveEmptyEntries); var headerLines = requestLines.Skip(1); foreach (var headerString in headerLines) { var headerKeyAndValue = headerString.Split(": "); var name = headerKeyAndValue[0]; var value = headerKeyAndValue[1]; headers = headers.AddHeader(name, value); } return(headers); }
public static Headers AsKafkaHeaders(this Metadata metadata) { var headers = new Headers(); // ReSharper disable once ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator foreach (var entry in metadata) { if (entry.Key == MetaTags.MessageId) { continue; } headers.AddHeader(entry.Key, entry.Value?.ToString()); } return(headers); }
public TextResult(byte[] content, HttpResponseStatusCode responseStatusCode, string contentType = "text/plain; charset=utf-8") : base(responseStatusCode) { Headers.AddHeader(new HttpHeader("Content-Type", contentType)); Content = content; }
public RedirectResult(string location, string content) : base(content, HttpResponseStatusCode.SeeOther) { Headers.AddHeader(new HttpHeader(Constants.LocationHeaderKey, location)); }
public void AddHeader(String key, Object value) { Headers.AddHeader(key, value); }
public UnauthorizedResult(string content) : base(HttpResponseStatusCode.Unauthorized) { Content = Encoding.UTF8.GetBytes(content); Headers.AddHeader(new HttpHeader(Constants.ContentLengthHeaderKey, Content.Length.ToString())); Headers.AddHeader(new HttpHeader(Constants.WWWAuthenticateHeaderKey, "Basic")); }
public HttpResponse(string content, HttpResponseStatusCode statusCode) : this(statusCode) { Content = Encoding.UTF8.GetBytes(content); Headers.AddHeader(new HttpHeader( Constants.ContentLengthHeaderKey, Content.Length.ToString())); }
public RedirectResult(string location) : base(HttpResponseStatusCode.SeeOther) { Headers.AddHeader(new HTTP.Headers.HttpHeader("Location", location)); }
public HtmlResult(string content, HttpResponseStatusCode responseStatusCode = HttpResponseStatusCode.Ok) : base(responseStatusCode) { Headers.AddHeader(new HttpHeader("Content-Type", "text/html; charset=utf-8")); Content = Encoding.UTF8.GetBytes(content); }
public TextResult(byte[] content, HttpResponseStatusCode httpResponseStatusCode, string contentType = @"text/plain charset=utf-8") : base(httpResponseStatusCode) { Content = content; Headers.AddHeader(new HTTP.Headers.HttpHeader("Content-Type", contentType)); }
public void AddHeader(HttpHeader header) { Headers.AddHeader(header); }
public InlineResourceResult(byte[] content) : base(HttpResponseStatusCode.OK) { Content = content; Headers.AddHeader(new HttpHeader(Constants.ContentDispositionHeaderKey, "inline")); Headers.AddHeader(new HttpHeader(Constants.ContentLengthHeaderKey, Content.Length.ToString())); }
public TextResult(string content, HttpResponseStatusCode httpResponseStatusCode, string contentType = @"text/plain charset=utf-8") : base(httpResponseStatusCode) { Headers.AddHeader(new HTTP.Headers.HttpHeader("Content-Type", contentType)); Content = Encoding.UTF8.GetBytes(content); }
public TextResponse(string content, HttpResponseStatusCode statusCode = HttpResponseStatusCode.OK) : base(content, statusCode) { Headers.AddHeader(new HttpHeader(Constants.ContentTypeHeaderKey, Constants.ContentTypeTextHeaderValue)); }
public NotFoundResult(string resourceType, string resourceName) : base(HttpResponseStatusCode.NotFound) { Content = Encoding.UTF8.GetBytes(string.Format(Constants.ResourceNotFoundMessage, resourceType, resourceName)); Headers.AddHeader(new HttpHeader(Constants.HttpContentLengthKey, Content.Length.ToString())); }