@Test public void shouldCreateNettyResponseWithCookieWithAttributes() { ResponseCookie cookie = responseCookie("cookie-test", "cookie-value") .domain("cookie-domain") .path("cookie-path") .maxAge(1234) .httpOnly(true) .secure(true) .build(); LiveHttpResponse styxResponse = new LiveHttpResponse.Builder(OK) .cookies(cookie) .build(); io.netty.handler.codec.http.HttpResponse nettyResponse = translator.toNettyResponse(styxResponse); String setCookie = nettyResponse.headers().get(SET_COOKIE); Cookie nettyCookie = ClientCookieDecoder.LAX.decode(setCookie); assertThat(nettyCookie.name(), is("cookie-test")); assertThat(nettyCookie.value(), is("cookie-value")); assertThat(nettyCookie.domain(), is("cookie-domain")); assertThat(nettyCookie.maxAge(), is(1234L)); assertThat(nettyCookie.isHttpOnly(), is(true)); assertThat(nettyCookie.isSecure(), is(true)); }
public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); DefaultHttpResponse nettyResponse = new DefaultHttpResponse(version, httpResponseStatus, true); httpResponse.headers().forEach(httpHeader -> nettyResponse.headers().add(httpHeader.name(), httpHeader.value())); return nettyResponse; }
StyxToNettyResponseTranslator implements ResponseTranslator { public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); DefaultHttpResponse nettyResponse = new DefaultHttpResponse(version, httpResponseStatus, true); httpResponse.headers().forEach(httpHeader -> nettyResponse.headers().add(httpHeader.name(), httpHeader.value())); return nettyResponse; } }
StyxToNettyResponseTranslator implements ResponseTranslator { public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); DefaultHttpResponse nettyResponse = new DefaultHttpResponse(version, httpResponseStatus, true); httpResponse.headers().forEach(httpHeader -> nettyResponse.headers().add(httpHeader.name(), httpHeader.value())); return nettyResponse; }  }
StyxToNettyResponseTranslator implements ResponseTranslator { public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); DefaultHttpResponse nettyResponse = new DefaultHttpResponse(version, httpResponseStatus, true); httpResponse.headers().forEach(httpHeader -> nettyResponse.headers().add(httpHeader.name(), httpHeader.value())); return nettyResponse; }  HttpResponse toNettyResponse(LiveHttpResponse httpResponse); }
StyxToNettyResponseTranslator implements ResponseTranslator { public HttpResponse toNettyResponse(LiveHttpResponse httpResponse) { io.netty.handler.codec.http.HttpVersion version = toNettyVersion(httpResponse.version()); HttpResponseStatus httpResponseStatus = HttpResponseStatus.valueOf(httpResponse.status().code()); DefaultHttpResponse nettyResponse = new DefaultHttpResponse(version, httpResponseStatus, true); httpResponse.headers().forEach(httpHeader -> nettyResponse.headers().add(httpHeader.name(), httpHeader.value())); return nettyResponse; }  HttpResponse toNettyResponse(LiveHttpResponse httpResponse);  }