private void setCookies(HttpRequest httpRequest, HttpServletRequest httpServletRequest) { Cookies cookies = new Cookies(); if (httpServletRequest.getCookies() != null) { for (javax.servlet.http.Cookie cookie : httpServletRequest.getCookies()) { cookies.withEntry(new Cookie(cookie.getName(), cookie.getValue())); } } httpRequest.withCookies(cookies); }
public Cookies clone() { return new Cookies().withEntries(getEntries()); } }
private void setCookies(HttpResponse httpResponse) { Cookies cookies = new Cookies(); for (Header header : httpResponse.getHeaderList()) { if (header.getName().getValue().equalsIgnoreCase("Set-Cookie")) { for (NottableString cookieHeader : header.getValues()) { io.netty.handler.codec.http.cookie.Cookie httpCookie = ClientCookieDecoder.LAX.decode(cookieHeader.getValue()); String name = httpCookie.name().trim(); String value = httpCookie.value().trim(); cookies.withEntry(new Cookie(name, value)); } } if (header.getName().getValue().equalsIgnoreCase("Cookie")) { for (NottableString cookieHeader : header.getValues()) { for (io.netty.handler.codec.http.cookie.Cookie httpCookie : ServerCookieDecoder.LAX.decode(cookieHeader.getValue())) { String name = httpCookie.name().trim(); String value = httpCookie.value().trim(); cookies.withEntry(new Cookie(name, value)); } } } } if (!cookies.isEmpty()) { httpResponse.withCookies(cookies); } }
/** * The cookies to return as Set-Cookie headers as a list of Cookie objects * * @param cookies a list of Cookie objects */ public HttpResponse withCookies(List<Cookie> cookies) { this.cookies.withEntries(cookies); return this; }
/** * Adds one cookie to match on, which can specified using either plain strings or regular expressions * (for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html) * * @param name the cookies name * @param value the cookies value */ public HttpRequest withCookie(String name, String value) { this.cookies.withEntry(name, value); return this; }
public List<Cookie> getCookieList() { return this.cookies.getEntries(); }
public HttpResponse clone() { return response() .withStatusCode(statusCode) .withReasonPhrase(reasonPhrase) .withBody(body) .withHeaders(headers.clone()) .withCookies(cookies.clone()) .withDelay(getDelay()) .withConnectionOptions(connectionOptions); } }
jgen.writeObjectField("headers", httpResponseDTO.getHeaders()); if (httpResponseDTO.getCookies() != null && !httpResponseDTO.getCookies().isEmpty()) { jgen.writeObjectField("cookies", httpResponseDTO.getCookies());
private void setCookies(HttpResponse httpResponse) { Cookies cookies = new Cookies(); for (Header header : httpResponse.getHeaderList()) { if (header.getName().getValue().equalsIgnoreCase("Set-Cookie")) { for (NottableString cookieHeader : header.getValues()) { io.netty.handler.codec.http.cookie.Cookie httpCookie = ClientCookieDecoder.LAX.decode(cookieHeader.getValue()); String name = httpCookie.name().trim(); String value = httpCookie.value().trim(); cookies.withEntry(new Cookie(name, value)); } } if (header.getName().getValue().equalsIgnoreCase("Cookie")) { for (NottableString cookieHeader : header.getValues()) { for (io.netty.handler.codec.http.cookie.Cookie httpCookie : ServerCookieDecoder.LAX.decode(cookieHeader.getValue())) { String name = httpCookie.name().trim(); String value = httpCookie.value().trim(); cookies.withEntry(new Cookie(name, value)); } } } } if (!cookies.isEmpty()) { httpResponse.withCookies(cookies); } }
/** * The cookies to return as Set-Cookie headers as a varargs of Cookie objects * * @param cookies a varargs of Cookie objects */ public HttpResponse withCookies(Cookie... cookies) { this.cookies.withEntries(cookies); return this; }
/** * Add cookie to return as Set-Cookie header * * @param name the cookies name * @param value the cookies value */ public HttpResponse withCookie(String name, String value) { this.cookies.withEntry(name, value); return this; }
public List<Cookie> getCookieList() { return this.cookies.getEntries(); }
public HttpRequest clone() { return not(request(), not) .withMethod(method) .withPath(path) .withQueryStringParameters(getQueryStringParameters().clone()) .withBody(body) .withHeaders(getHeaders().clone()) .withCookies(getCookies().clone()) .withKeepAlive(keepAlive) .withSecure(secure); }
jgen.writeObjectField("headers", httpRequest.getHeaders()); if (httpRequest.getCookies() != null && !httpRequest.getCookies().isEmpty()) { jgen.writeObjectField("cookies", httpRequest.getCookies());
private Cookies deserializeObject(JsonParser jsonParser, DeserializationContext ctxt, JsonNodeFactory nodeFactory) throws IOException { Cookies cookies = new Cookies(); NottableString key = string(""); while (true) { JsonToken t = jsonParser.nextToken(); switch (t.id()) { case JsonTokenId.ID_FIELD_NAME: key = string(jsonParser.getText()); break; case JsonTokenId.ID_STRING: cookies.withEntry(key, string(ctxt.readValue(jsonParser, String.class))); break; case JsonTokenId.ID_END_OBJECT: return cookies; default: throw new RuntimeException("Unexpected token: \"" + t + "\" id: \"" + t.id() + "\" text: \"" + jsonParser.getText()); } } }
public Cookies clone() { return new Cookies().withEntries(getEntries()); } }
/** * The cookies to match on as a list of Cookie objects where the values or keys of each cookie can be either a string or a regex * (for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html) * * @param cookies a list of Cookie objects */ public HttpRequest withCookies(List<Cookie> cookies) { this.cookies.withEntries(cookies); return this; }
/** * Adds one cookie to match on as a Cookie object where the cookie values list can be a list of strings or regular expressions * (for more details of the supported regex syntax see http://docs.oracle.com/javase/6/docs/api/java/util/regex/Pattern.html) * * @param cookie a Cookie object */ public HttpRequest withCookie(Cookie cookie) { this.cookies.withEntry(cookie); return this; }
@Override public void serialize(Cookies collection, JsonGenerator jgen, SerializerProvider provider) throws IOException { jgen.writeStartObject(); for (Cookie cookie : collection.getEntries()) { jgen.writeStringField(serialiseNottableString(cookie.getName()), serialiseNottableString(cookie.getValue())); } jgen.writeEndObject(); }
public HttpResponse clone() { return response() .withStatusCode(statusCode) .withReasonPhrase(reasonPhrase) .withBody(body) .withHeaders(headers.clone()) .withCookies(cookies.clone()) .withDelay(getDelay()) .withConnectionOptions(connectionOptions); } }