bool SetOrigin(IHttpResponse response) { if (!this.request.Headers.TryGet(HttpHeaderNames.Origin, out ICharSequence origin)) { return(false); } if (NullOrigin.ContentEquals(origin) && this.config.IsNullOriginAllowed) { SetNullOrigin(response); return(true); } if (this.config.IsAnyOriginSupported) { if (this.config.IsCredentialsAllowed) { this.EchoRequestOrigin(response); SetVaryHeader(response); } else { SetAnyOrigin(response); } return(true); } if (this.config.Origins.Contains(origin)) { SetOrigin(response, origin); SetVaryHeader(response); return(true); } Logger.Debug("Request origin [{}]] was not among the configured origins [{}]", origin, this.config.Origins); return(false); }
void SetAllowCredentials(IHttpResponse response) { if (this.config.IsCredentialsAllowed && !AsciiString.ContentEquals(response.Headers.Get(HttpHeaderNames.AccessControlAllowOrigin, null), AnyOrigin)) { response.Headers.Set(HttpHeaderNames.AccessControlAllowCredentials, new AsciiString("true")); } }
public HttpServerUpgradeHandler.IUpgradeCodec NewUpgradeCodec(ICharSequence protocol) { if (AsciiString.ContentEquals(Http2CodecUtil.HttpUpgradeProtocolName, protocol)) { return(new Http2ServerUpgradeCodec(Http2FrameCodecBuilder.ForServer().Build(), new HelloWorldHttp2Handler())); } else { return(null); } }
static void AssertDefaultValues(HttpHeaders headers, HttpHeadersTestUtils.HeaderValue headerValue) { Assert.True(AsciiString.ContentEquals(headerValue.AsList()[0], (StringCharSequence)headers.Get(HeaderName, null))); List <ICharSequence> expected = headerValue.AsList(); IList <ICharSequence> actual = headers.GetAll(HeaderName); Assert.Equal(expected.Count, actual.Count); for (int i = 0; i < expected.Count; i++) { Assert.True(AsciiString.ContentEquals(expected[i], (StringCharSequence)actual[i])); } }
bool SetOrigin(IHttpResponse response) { if (!this.request.Headers.TryGet(HttpHeaderNames.Origin, out ICharSequence origin) || this.config is null) { return(false); } if (NullOrigin.ContentEquals(origin) && this.config.IsNullOriginAllowed) { SetNullOrigin(response); return(true); } if (this.config.IsAnyOriginSupported) { if (this.config.IsCredentialsAllowed) { this.EchoRequestOrigin(response); SetVaryHeader(response); } else { SetAnyOrigin(response); } return(true); } if (this.config.Origins.Contains(origin)) { SetOrigin(response, origin); SetVaryHeader(response); return(true); } #if DEBUG if (Logger.DebugEnabled) { Logger.RequestOriginWasNotAmongTheConfiguredOrigins(origin, this.config); } #endif return(false); }
internal static bool EqualsVariableTime(ICharSequence s1, ICharSequence s2) { return(AsciiString.ContentEquals(s1, s2)); }