curlString.append("'"); if (!hasDefaultMethod(request)) { curlString.append(" -X ").append(request.getMethod().getValue());
} else { if (request != null) { boolean methodMatches = Strings.isNullOrEmpty(request.getMethod().getValue()) || matches(context, methodMatcher, request.getMethod()); boolean pathMatches = Strings.isNullOrEmpty(request.getPath().getValue()) || matches(context, pathMatcher, request.getPath()); boolean queryStringParametersMatches = matches(context, queryStringParameterMatcher, request.getQueryStringParameters());
public static boolean isPreflightRequest(HttpRequest request) { final Headers headers = request.getHeaders(); return request.getMethod().getValue().equals(OPTIONS.name()) && headers.containsEntry(HttpHeaderNames.ORIGIN.toString()) && headers.containsEntry(HttpHeaderNames.ACCESS_CONTROL_REQUEST_METHOD.toString()); }
public void renderDashboard(final ChannelHandlerContext ctx, final HttpRequest request) throws Exception { HttpResponse response = notFoundResponse(); if (request.getMethod().getValue().equals("GET")) { String path = StringUtils.substringAfter(request.getPath().getValue(), PATH_PREFIX + "/dashboard"); if (path.isEmpty() || path.equals("/")) {
public FullHttpRequest mapMockServerResponseToHttpServletResponse(HttpRequest httpRequest) { // method HttpMethod httpMethod = HttpMethod.valueOf(httpRequest.getMethod("GET")); // the request FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, httpMethod, getURI(httpRequest), getBody(httpRequest)); // headers setHeader(httpRequest, request); // cookies setCookies(httpRequest, request); return request; }
appendNewLineAndIndent(numberOfSpacesToIndent * INDENT_SIZE, output); output.append("request()"); if (!Strings.isNullOrEmpty(request.getMethod().getValue())) { appendNewLineAndIndent((numberOfSpacesToIndent + 1) * INDENT_SIZE, output); output.append(".withMethod(\"").append(request.getMethod().getValue()).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; } }
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()); } }
public static boolean isPreflightRequest(HttpRequest request) { final Headers headers = request.getHeaders(); return request.getMethod().getValue().equals(OPTIONS.name()) && headers.containsEntry(HttpHeaderNames.ORIGIN.toString()) && headers.containsEntry(HttpHeaderNames.ACCESS_CONTROL_REQUEST_METHOD.toString()); }
public FullHttpRequest mapMockServerResponseToHttpServletResponse(HttpRequest httpRequest) { // method HttpMethod httpMethod = HttpMethod.valueOf(httpRequest.getMethod("GET")); // the request FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, httpMethod, getURI(httpRequest), getBody(httpRequest)); // headers setHeader(httpRequest, request); // cookies setCookies(httpRequest, request); return request; }
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 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()); } }