use of io.netty.handler.codec.http.cookie.Cookie in project riposte by Nike-Inc.
the class HttpUtilsTest method extractCookies_does_not_use_trailing_headers_if_trailing_headers_is_null.
@Test
public void extractCookies_does_not_use_trailing_headers_if_trailing_headers_is_null() {
// given
HttpRequest nettyRequestMock = mock(HttpRequest.class);
doReturn(new DefaultHttpHeaders()).when(nettyRequestMock).headers();
// when
Set<Cookie> extractedCookies = HttpUtils.extractCookies(nettyRequestMock);
// then
assertThat(extractedCookies, notNullValue());
assertThat(extractedCookies.isEmpty(), is(true));
}
use of io.netty.handler.codec.http.cookie.Cookie in project riposte by Nike-Inc.
the class ChunkedResponseInfoTest method uber_constructor_for_chunked_response_sets_fields_as_expected.
@Test
public void uber_constructor_for_chunked_response_sets_fields_as_expected() {
// given
int httpStatusCode = 200;
HttpHeaders headers = new DefaultHttpHeaders();
String mimeType = "text/text";
Charset contentCharset = CharsetUtil.UTF_8;
Set<Cookie> cookies = Sets.newHashSet(new DefaultCookie("key1", "val1"), new DefaultCookie("key2", "val2"));
boolean preventCompressedResponse = true;
// when
ChunkedResponseInfo responseInfo = new ChunkedResponseInfo(httpStatusCode, headers, mimeType, contentCharset, cookies, preventCompressedResponse);
// then
assertThat(responseInfo.getHttpStatusCode(), is(httpStatusCode));
assertThat(responseInfo.getHeaders(), is(headers));
assertThat(responseInfo.getDesiredContentWriterMimeType(), is(mimeType));
assertThat(responseInfo.getDesiredContentWriterEncoding(), is(contentCharset));
assertThat(responseInfo.getCookies(), is(cookies));
assertThat(responseInfo.getUncompressedRawContentLength(), nullValue());
assertThat(responseInfo.getFinalContentLength(), nullValue());
assertThat(responseInfo.isPreventCompressedOutput(), is(preventCompressedResponse));
assertThat(responseInfo.isChunkedResponse(), is(true));
assertThat(responseInfo.isResponseSendingStarted(), is(false));
assertThat(responseInfo.isResponseSendingLastChunkSent(), is(false));
}
use of io.netty.handler.codec.http.cookie.Cookie in project spring-framework by spring-projects.
the class RxNettyServerHttpRequest method initCookies.
@Override
protected MultiValueMap<String, HttpCookie> initCookies() {
MultiValueMap<String, HttpCookie> cookies = new LinkedMultiValueMap<>();
for (String name : this.request.getCookies().keySet()) {
for (Cookie cookie : this.request.getCookies().get(name)) {
HttpCookie httpCookie = new HttpCookie(name, cookie.value());
cookies.add(name, httpCookie);
}
}
return cookies;
}
use of io.netty.handler.codec.http.cookie.Cookie in project cxf by apache.
the class HttpSessionInterceptor method onRequestReceived.
@Override
public void onRequestReceived(ChannelHandlerContext ctx, HttpRequest request) {
HttpSessionThreadLocal.unset();
Collection<Cookie> cookies = Utils.getCookies(NettyHttpSession.SESSION_ID_KEY, request);
if (cookies != null) {
for (Cookie cookie : cookies) {
String jsessionId = cookie.value();
NettyHttpSession s = HttpSessionThreadLocal.getSessionStore().findSession(jsessionId);
if (s != null) {
HttpSessionThreadLocal.set(s);
this.sessionRequestedByCookie = true;
break;
}
}
}
}
use of io.netty.handler.codec.http.cookie.Cookie in project riposte by Nike-Inc.
the class HttpUtils method extractCookies.
public static Set<Cookie> extractCookies(HttpRequest request) {
Set<Cookie> cookies = new HashSet<>();
HttpHeaders trailingHeaders = extractTrailingHeadersIfPossible(request);
String cookieString = request.headers().get(COOKIE);
if (cookieString == null && trailingHeaders != null)
cookieString = trailingHeaders.get(COOKIE);
if (cookieString != null)
cookies.addAll(ServerCookieDecoder.LAX.decode(cookieString));
return cookies;
}
Aggregations