private void writeAndCloseSocket(ChannelHandlerContext ctx, HttpRequest request, HttpResponse response) { boolean closeChannel; ConnectionOptions connectionOptions = response.getConnectionOptions(); if (connectionOptions != null && connectionOptions.getCloseSocket() != null) { closeChannel = connectionOptions.getCloseSocket(); } else { closeChannel = !(request.isKeepAlive() != null && request.isKeepAlive()); } if (closeChannel) { ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE); } else { ctx.writeAndFlush(response); } }
boolean headersMatch = matches(context, headerMatcher, request.getHeaders()); boolean cookiesMatch = matches(context, cookieMatcher, request.getCookies()); boolean keepAliveMatches = matches(context, keepAliveMatcher, request.isKeepAlive()); boolean sslMatches = matches(context, sslMatcher, request.isSecure());
.withBody(bytes); if (request.isKeepAlive()) { response.withHeader(HttpHeaderNames.CONNECTION.toString(), HttpHeaderValues.KEEP_ALIVE.toString()); if (!request.isKeepAlive()) { ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE); } else {
jgen.writeObjectField("cookies", httpRequest.getCookies()); if (httpRequest.isKeepAlive() != null) { jgen.writeBooleanField("keepAlive", httpRequest.isKeepAlive());
output.append(".withSecure(").append(request.isSecure().toString()).append(")"); if (request.isKeepAlive() != null) { appendNewLineAndIndent((numberOfSpacesToIndent + 1) * INDENT_SIZE, output); output.append(".withKeepAlive(").append(request.isKeepAlive().toString()).append(")");
public HttpRequestDTO(HttpRequest httpRequest, Boolean not) { super(not); if (httpRequest != null) { method = httpRequest.getMethod(); path = httpRequest.getPath(); headers = httpRequest.getHeaders(); cookies = httpRequest.getCookies(); queryStringParameters = httpRequest.getQueryStringParameters(); body = BodyDTO.createDTO(httpRequest.getBody()); keepAlive = httpRequest.isKeepAlive(); secure = httpRequest.isSecure(); } }
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(); } }
public HttpRequest update(HttpRequest replaceRequest) { if (!Strings.isNullOrEmpty(replaceRequest.getMethod().getValue())) { withMethod(replaceRequest.getMethod()); } if (!Strings.isNullOrEmpty(replaceRequest.getPath().getValue())) { withPath(replaceRequest.getPath()); } for (Header header : replaceRequest.getHeaderList()) { getHeaders().replaceEntry(header); } for (Cookie cookie : replaceRequest.getCookieList()) { withCookie(cookie); } for (Parameter parameter : replaceRequest.getQueryStringParameterList()) { getQueryStringParameters().replaceEntry(parameter); } if (replaceRequest.getBody() != null) { withBody(replaceRequest.getBody()); } if (replaceRequest.isSecure() != null) { withSecure(replaceRequest.isSecure()); } if (replaceRequest.isKeepAlive() != null) { withKeepAlive(replaceRequest.isKeepAlive()); } return this; } }
protected void addConnectionHeader(HttpRequest request, HttpResponse response) { ConnectionOptions connectionOptions = response.getConnectionOptions(); if (connectionOptions != null && connectionOptions.getKeepAliveOverride() != null) { if (connectionOptions.getKeepAliveOverride()) { response.replaceHeader(header(CONNECTION.toString(), KEEP_ALIVE.toString())); } else { response.replaceHeader(header(CONNECTION.toString(), CLOSE.toString())); } } else if (connectionOptions == null || isFalseOrNull(connectionOptions.getSuppressConnectionHeader())) { if (request.isKeepAlive() != null && request.isKeepAlive() && (connectionOptions == null || isFalseOrNull(connectionOptions.getCloseSocket()))) { response.replaceHeader(header(CONNECTION.toString(), KEEP_ALIVE.toString())); } else { response.replaceHeader(header(CONNECTION.toString(), CLOSE.toString())); } } } }
public HttpRequestMatcher(HttpRequest httpRequest, MockServerLogger mockServerLogger) { this.httpRequest = httpRequest; this.mockServerLogger = mockServerLogger; if (httpRequest != null) { withMethod(httpRequest.getMethod()); withPath(httpRequest.getPath()); withQueryStringParameters(httpRequest.getQueryStringParameters()); withBody(httpRequest.getBody()); withHeaders(httpRequest.getHeaders()); withCookies(httpRequest.getCookies()); withKeepAlive(httpRequest.isKeepAlive()); withSsl(httpRequest.isSecure()); } }
public HttpRequestMatcher(Expectation expectation, MockServerLogger mockServerLogger) { this.expectation = expectation; this.httpRequest = expectation.getHttpRequest(); this.mockServerLogger = mockServerLogger; if (httpRequest != null) { withMethod(httpRequest.getMethod()); withPath(httpRequest.getPath()); withQueryStringParameters(httpRequest.getQueryStringParameters()); withBody(httpRequest.getBody()); withHeaders(httpRequest.getHeaders()); withCookies(httpRequest.getCookies()); withKeepAlive(httpRequest.isKeepAlive()); withSsl(httpRequest.isSecure()); } }
private void writeAndCloseSocket(ChannelHandlerContext ctx, HttpRequest request, HttpResponse response) { boolean closeChannel; ConnectionOptions connectionOptions = response.getConnectionOptions(); if (connectionOptions != null && connectionOptions.getCloseSocket() != null) { closeChannel = connectionOptions.getCloseSocket(); } else { closeChannel = !(request.isKeepAlive() != null && request.isKeepAlive()); } if (closeChannel) { ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE); } else { ctx.writeAndFlush(response); } }
.withBody(bytes); if (request.isKeepAlive()) { response.withHeader(HttpHeaderNames.CONNECTION.toString(), HttpHeaderValues.KEEP_ALIVE.toString()); if (!request.isKeepAlive()) { ctx.writeAndFlush(response).addListener(ChannelFutureListener.CLOSE); } else {
jgen.writeObjectField("cookies", httpRequest.getCookies()); if (httpRequest.isKeepAlive() != null) { jgen.writeBooleanField("keepAlive", httpRequest.isKeepAlive());
public HttpRequestDTO(HttpRequest httpRequest, Boolean not) { super(not); if (httpRequest != null) { method = httpRequest.getMethod(); path = httpRequest.getPath(); headers = httpRequest.getHeaders(); cookies = httpRequest.getCookies(); queryStringParameters = httpRequest.getQueryStringParameters(); body = BodyDTO.createDTO(httpRequest.getBody()); keepAlive = httpRequest.isKeepAlive(); secure = httpRequest.isSecure(); } }
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(); } }
public HttpRequest update(HttpRequest replaceRequest) { if (!Strings.isNullOrEmpty(replaceRequest.getMethod().getValue())) { withMethod(replaceRequest.getMethod()); } if (!Strings.isNullOrEmpty(replaceRequest.getPath().getValue())) { withPath(replaceRequest.getPath()); } for (Header header : replaceRequest.getHeaderList()) { getHeaders().replaceEntry(header); } for (Cookie cookie : replaceRequest.getCookieList()) { withCookie(cookie); } for (Parameter parameter : replaceRequest.getQueryStringParameterList()) { getQueryStringParameters().replaceEntry(parameter); } if (replaceRequest.getBody() != null) { withBody(replaceRequest.getBody()); } if (replaceRequest.isSecure() != null) { withSecure(replaceRequest.isSecure()); } if (replaceRequest.isKeepAlive() != null) { withKeepAlive(replaceRequest.isKeepAlive()); } return this; } }
protected void addConnectionHeader(HttpRequest request, HttpResponse response) { ConnectionOptions connectionOptions = response.getConnectionOptions(); if (connectionOptions != null && connectionOptions.getKeepAliveOverride() != null) { if (connectionOptions.getKeepAliveOverride()) { response.replaceHeader(header(CONNECTION.toString(), KEEP_ALIVE.toString())); } else { response.replaceHeader(header(CONNECTION.toString(), CLOSE.toString())); } } else if (connectionOptions == null || isFalseOrNull(connectionOptions.getSuppressConnectionHeader())) { if (request.isKeepAlive() != null && request.isKeepAlive() && (connectionOptions == null || isFalseOrNull(connectionOptions.getCloseSocket()))) { response.replaceHeader(header(CONNECTION.toString(), KEEP_ALIVE.toString())); } else { response.replaceHeader(header(CONNECTION.toString(), CLOSE.toString())); } } } }
public HttpRequestMatcher(HttpRequest httpRequest, MockServerLogger mockServerLogger) { this.httpRequest = httpRequest; this.mockServerLogger = mockServerLogger; if (httpRequest != null) { withMethod(httpRequest.getMethod()); withPath(httpRequest.getPath()); withQueryStringParameters(httpRequest.getQueryStringParameters()); withBody(httpRequest.getBody()); withHeaders(httpRequest.getHeaders()); withCookies(httpRequest.getCookies()); withKeepAlive(httpRequest.isKeepAlive()); withSsl(httpRequest.isSecure()); } }
public HttpRequestMatcher(Expectation expectation, MockServerLogger mockServerLogger) { this.expectation = expectation; this.httpRequest = expectation.getHttpRequest(); this.mockServerLogger = mockServerLogger; if (httpRequest != null) { withMethod(httpRequest.getMethod()); withPath(httpRequest.getPath()); withQueryStringParameters(httpRequest.getQueryStringParameters()); withBody(httpRequest.getBody()); withHeaders(httpRequest.getHeaders()); withCookies(httpRequest.getCookies()); withKeepAlive(httpRequest.isKeepAlive()); withSsl(httpRequest.isSecure()); } }