private static void AddResponseFieldIfConfigured(Request request, HttpField field) { if (field != null) { request.Response.HttpFields.add(field); } }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: public void handle(String target, org.eclipse.jetty.server.Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException, javax.servlet.ServletException public override void Handle(string target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) { HttpChannel httpChannel = baseRequest.HttpChannel; if (httpChannel != null) // if the channel is not null, all good, you handle yourself. { base.Handle(target, baseRequest, request, response); } else // if we do not have a real channel, then we just log ourselves { try { if (_handler != null) { _handler.handle(target, baseRequest, request, response); } } finally { RequestLog requestLog = RequestLog; if (requestLog != null && baseRequest.DispatcherType == DispatcherType.REQUEST) { requestLog.log(baseRequest, ( Response )response); } } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldSetRequestSchemeToHttps() public virtual void ShouldSetRequestSchemeToHttps() { Customizer customizer = NewCustomizer(); Request request = mock(typeof(Request)); Customize(customizer, request); verify(request).Scheme = HTTPS.asString(); }
private static Request NewRequest() { HttpChannel channel = mock(typeof(HttpChannel)); Response response = new Response(channel, mock(typeof(HttpOutput))); Request request = new Request(channel, mock(typeof(HttpInput))); when(channel.Request).thenReturn(request); when(channel.Response).thenReturn(response); return(request); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldNotAddHstsHeaderWhenNotConfigured() public virtual void ShouldNotAddHstsHeaderWhenNotConfigured() { Customizer customizer = NewCustomizer(); Request request = NewRequest(); Customize(customizer, request); string hstsValue = request.Response.HttpFields.get(STRICT_TRANSPORT_SECURITY); assertNull(hstsValue); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldAddHstsHeaderWhenConfigured() public virtual void ShouldAddHstsHeaderWhenConfigured() { string configuredValue = "max-age=3600; includeSubDomains"; Customizer customizer = NewCustomizer(configuredValue); Request request = NewRequest(); Customize(customizer, request); string receivedValue = request.Response.HttpFields.get(STRICT_TRANSPORT_SECURITY); assertEquals(configuredValue, receivedValue); }
public override void Customize(Connector connector, HttpConfiguration channelConfig, Request request) { request.Scheme = HttpScheme.HTTPS.asString(); AddResponseFieldIfConfigured(request, _hstsResponseField); }
private static void Customize(Customizer customizer, Request request) { customizer.customize(mock(typeof(Connector)), new HttpConfiguration(), request); }