@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(); }
private String getCookieHeader(HttpRequest request) { List<Cookie> cookies = new ArrayList<Cookie>(); for (org.mockserver.model.Cookie cookie : request.getCookieList()) { cookies.add(new DefaultCookie(cookie.getName().getValue(), cookie.getValue().getValue())); } if (cookies.size() > 0) { return " -H '" + COOKIE + ": " + ClientCookieEncoder.LAX.encode(cookies) + "'"; } else { return ""; } } }
private void setCookies(HttpRequest httpRequest, FullHttpRequest request) { List<io.netty.handler.codec.http.cookie.Cookie> cookies = new ArrayList<io.netty.handler.codec.http.cookie.Cookie>(); for (org.mockserver.model.Cookie cookie : httpRequest.getCookieList()) { cookies.add(new io.netty.handler.codec.http.cookie.DefaultCookie(cookie.getName().getValue(), cookie.getValue().getValue())); } if (cookies.size() > 0) { request.headers().set( COOKIE.toString(), io.netty.handler.codec.http.cookie.ClientCookieEncoder.LAX.encode(cookies) ); } }
@Override public String serialize(int numberOfSpacesToIndent, Cookie cookie) { return NEW_LINE + Strings.padStart("", numberOfSpacesToIndent * INDENT_SIZE, ' ') + "new Cookie(" + NottableStringToJavaSerializer.serializeNottableString(cookie.getName()) + ", " + NottableStringToJavaSerializer.serializeNottableString(cookie.getValue()) + ")"; }
private void setCookies(HttpResponse response, DefaultFullHttpResponse fullHttpResponse) { if (response.getCookieList() != null) { List<Cookie> cookieValues = new ArrayList<Cookie>(); for (org.mockserver.model.Cookie cookie : response.getCookieList()) { if (!cookieHeaderAlreadyExists(response, cookie)) { cookieValues.add(new DefaultCookie(cookie.getName().getValue(), cookie.getValue().getValue())); } } for (Cookie cookieValue : cookieValues) { fullHttpResponse.headers().add(SET_COOKIE, ServerCookieEncoder.LAX.encode(cookieValue)); } } }
private boolean cookieHeaderAlreadyExists(HttpResponse response, org.mockserver.model.Cookie cookieValue) { List<String> setCookieHeaders = response.getHeader(SET_COOKIE.toString()); for (String setCookieHeader : setCookieHeaders) { String existingCookieName = ClientCookieDecoder.LAX.decode(setCookieHeader).name(); String existingCookieValue = ClientCookieDecoder.LAX.decode(setCookieHeader).value(); if (existingCookieName.equalsIgnoreCase(cookieValue.getName().getValue()) && existingCookieValue.equalsIgnoreCase(cookieValue.getValue().getValue())) { return true; } } return false; } }
private boolean cookieHeaderAlreadyExists(HttpResponse response, Cookie cookieValue) { List<String> setCookieHeaders = response.getHeader(SET_COOKIE.toString()); for (String setCookieHeader : setCookieHeaders) { String existingCookieName = ClientCookieDecoder.LAX.decode(setCookieHeader).name(); String existingCookieValue = ClientCookieDecoder.LAX.decode(setCookieHeader).value(); if (existingCookieName.equalsIgnoreCase(cookieValue.getName().getValue()) && existingCookieValue.equalsIgnoreCase(cookieValue.getValue().getValue())) { return true; } } return false; }
private void setCookies(HttpResponse httpResponse, HttpServletResponse httpServletResponse) { if (httpResponse.getCookieList() != null) { for (Cookie cookie : httpResponse.getCookieList()) { if (!cookieHeaderAlreadyExists(httpResponse, cookie)) { httpServletResponse.addHeader(SET_COOKIE.toString(), ServerCookieEncoder.LAX.encode(new DefaultCookie(cookie.getName().getValue(), cookie.getValue().getValue()))); } } } }
public HttpRequestTemplateObject(HttpRequest httpRequest) { if (httpRequest != null) { method = httpRequest.getMethod().getValue(); path = httpRequest.getPath().getValue(); for (Header header : httpRequest.getHeaderList()) { headers.put(header.getName().getValue(), Lists.transform(header.getValues(), new Function<NottableString, String>() { public String apply(NottableString input) { return input.getValue(); } })); } for (Cookie cookie : httpRequest.getCookieList()) { cookies.put(cookie.getName().getValue(), cookie.getValue().getValue()); } for (Parameter parameter : httpRequest.getQueryStringParameterList()) { queryStringParameters.put(parameter.getName().getValue(), Lists.transform(parameter.getValues(), new Function<NottableString, String>() { public String apply(NottableString input) { return input.getValue(); } })); } body = BodyDTO.createDTO(httpRequest.getBody()); keepAlive = httpRequest.isKeepAlive(); secure = httpRequest.isSecure(); } }
@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(); }
private String getCookieHeader(HttpRequest request) { List<Cookie> cookies = new ArrayList<Cookie>(); for (org.mockserver.model.Cookie cookie : request.getCookieList()) { cookies.add(new DefaultCookie(cookie.getName().getValue(), cookie.getValue().getValue())); } if (cookies.size() > 0) { return " -H '" + COOKIE + ": " + ClientCookieEncoder.LAX.encode(cookies) + "'"; } else { return ""; } } }
private void setCookies(HttpRequest httpRequest, FullHttpRequest request) { List<io.netty.handler.codec.http.cookie.Cookie> cookies = new ArrayList<io.netty.handler.codec.http.cookie.Cookie>(); for (org.mockserver.model.Cookie cookie : httpRequest.getCookieList()) { cookies.add(new io.netty.handler.codec.http.cookie.DefaultCookie(cookie.getName().getValue(), cookie.getValue().getValue())); } if (cookies.size() > 0) { request.headers().set( COOKIE.toString(), io.netty.handler.codec.http.cookie.ClientCookieEncoder.LAX.encode(cookies) ); } }
@Override public String serialize(int numberOfSpacesToIndent, Cookie cookie) { return NEW_LINE + Strings.padStart("", numberOfSpacesToIndent * INDENT_SIZE, ' ') + "new Cookie(" + NottableStringToJavaSerializer.serializeNottableString(cookie.getName()) + ", " + NottableStringToJavaSerializer.serializeNottableString(cookie.getValue()) + ")"; }
private void setCookies(HttpResponse response, DefaultFullHttpResponse fullHttpResponse) { if (response.getCookieList() != null) { List<Cookie> cookieValues = new ArrayList<Cookie>(); for (org.mockserver.model.Cookie cookie : response.getCookieList()) { if (!cookieHeaderAlreadyExists(response, cookie)) { cookieValues.add(new DefaultCookie(cookie.getName().getValue(), cookie.getValue().getValue())); } } for (Cookie cookieValue : cookieValues) { fullHttpResponse.headers().add(SET_COOKIE, ServerCookieEncoder.LAX.encode(cookieValue)); } } }
private boolean cookieHeaderAlreadyExists(HttpResponse response, org.mockserver.model.Cookie cookieValue) { List<String> setCookieHeaders = response.getHeader(SET_COOKIE.toString()); for (String setCookieHeader : setCookieHeaders) { String existingCookieName = ClientCookieDecoder.LAX.decode(setCookieHeader).name(); String existingCookieValue = ClientCookieDecoder.LAX.decode(setCookieHeader).value(); if (existingCookieName.equalsIgnoreCase(cookieValue.getName().getValue()) && existingCookieValue.equalsIgnoreCase(cookieValue.getValue().getValue())) { return true; } } return false; } }
private boolean cookieHeaderAlreadyExists(HttpResponse response, Cookie cookieValue) { List<String> setCookieHeaders = response.getHeader(SET_COOKIE.toString()); for (String setCookieHeader : setCookieHeaders) { String existingCookieName = ClientCookieDecoder.LAX.decode(setCookieHeader).name(); String existingCookieValue = ClientCookieDecoder.LAX.decode(setCookieHeader).value(); if (existingCookieName.equalsIgnoreCase(cookieValue.getName().getValue()) && existingCookieValue.equalsIgnoreCase(cookieValue.getValue().getValue())) { return true; } } return false; }
private void setCookies(HttpResponse httpResponse, HttpServletResponse httpServletResponse) { if (httpResponse.getCookieList() != null) { for (Cookie cookie : httpResponse.getCookieList()) { if (!cookieHeaderAlreadyExists(httpResponse, cookie)) { httpServletResponse.addHeader(SET_COOKIE.toString(), ServerCookieEncoder.LAX.encode(new DefaultCookie(cookie.getName().getValue(), cookie.getValue().getValue()))); } } } }
public HttpRequestTemplateObject(HttpRequest httpRequest) { if (httpRequest != null) { method = httpRequest.getMethod().getValue(); path = httpRequest.getPath().getValue(); for (Header header : httpRequest.getHeaderList()) { headers.put(header.getName().getValue(), Lists.transform(header.getValues(), new Function<NottableString, String>() { public String apply(NottableString input) { return input.getValue(); } })); } for (Cookie cookie : httpRequest.getCookieList()) { cookies.put(cookie.getName().getValue(), cookie.getValue().getValue()); } for (Parameter parameter : httpRequest.getQueryStringParameterList()) { queryStringParameters.put(parameter.getName().getValue(), Lists.transform(parameter.getValues(), new Function<NottableString, String>() { public String apply(NottableString input) { return input.getValue(); } })); } body = BodyDTO.createDTO(httpRequest.getBody()); keepAlive = httpRequest.isKeepAlive(); secure = httpRequest.isSecure(); } }