Search in sources :

Example 51 with DefaultHttpHeaders

use of io.netty.handler.codec.http.DefaultHttpHeaders in project tesla by linking12.

the class HttpRequestFilter method createResponse.

protected HttpResponse createResponse(HttpResponseStatus httpResponseStatus, HttpRequest originalRequest) {
    HttpHeaders httpHeaders = new DefaultHttpHeaders();
    httpHeaders.add("Transfer-Encoding", "chunked");
    HttpResponse httpResponse = new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, httpResponseStatus);
    List<String> originHeader = FilterUtil.getHeaderValues(originalRequest, "Origin");
    if (originHeader.size() > 0) {
        httpHeaders.set("Access-Control-Allow-Credentials", "true");
        httpHeaders.set("Access-Control-Allow-Origin", originHeader.get(0));
    }
    httpResponse.headers().add(httpHeaders);
    return httpResponse;
}
Also used : HttpHeaders(io.netty.handler.codec.http.HttpHeaders) DefaultHttpHeaders(io.netty.handler.codec.http.DefaultHttpHeaders) DefaultFullHttpResponse(io.netty.handler.codec.http.DefaultFullHttpResponse) DefaultHttpHeaders(io.netty.handler.codec.http.DefaultHttpHeaders) DefaultFullHttpResponse(io.netty.handler.codec.http.DefaultFullHttpResponse) HttpResponse(io.netty.handler.codec.http.HttpResponse)

Aggregations

DefaultHttpHeaders (io.netty.handler.codec.http.DefaultHttpHeaders)51 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)38 Test (org.testng.annotations.Test)20 Test (org.junit.Test)18 Cookie (io.netty.handler.codec.http.cookie.Cookie)14 DefaultCookie (io.netty.handler.codec.http.cookie.DefaultCookie)12 HttpServletResponse (javax.servlet.http.HttpServletResponse)12 HttpTest (org.asynchttpclient.testserver.HttpTest)12 AsyncCompletionHandlerAdapter (org.asynchttpclient.test.TestUtils.AsyncCompletionHandlerAdapter)11 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)9 Charset (java.nio.charset.Charset)8 HttpResponseHeaders (org.asynchttpclient.HttpResponseHeaders)6 HttpRequest (io.netty.handler.codec.http.HttpRequest)5 RequestInfo (com.nike.riposte.server.http.RequestInfo)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Map (java.util.Map)4 ByteBuf (io.netty.buffer.ByteBuf)3 Channel (io.netty.channel.Channel)3 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3