private void setHeaders(HttpResponse httpResponse, FullHttpResponse fullHttpResponse) { Headers headers = new Headers(); for (String headerName : fullHttpResponse.headers().names()) { headers.withEntry(new Header(headerName, fullHttpResponse.headers().getAll(headerName))); } if (!headers.isEmpty()) { httpResponse.withHeaders(headers); } }
response() .withStatusCode(request.getPath().equalsIgnoreCase("/not_found") ? NOT_FOUND.code() : OK.code()) .withHeaders(request.getHeaderList());
httpResponse.withHeaders(headers); return httpResponse; } catch (Exception ex) {
public HttpResponse buildObject() { return new HttpResponse() .withStatusCode(statusCode) .withReasonPhrase(reasonPhrase) .withBody(body != null ? body.buildObject() : null) .withHeaders(headers) .withCookies(cookies) .withDelay((delay != null ? delay.buildObject() : null)) .withConnectionOptions((connectionOptions != null ? connectionOptions.buildObject() : null)); }
public HttpResponse clone() { return response() .withStatusCode(statusCode) .withReasonPhrase(reasonPhrase) .withBody(body) .withHeaders(headers.clone()) .withCookies(cookies.clone()) .withDelay(getDelay()) .withConnectionOptions(connectionOptions); } }
.withStatusCode(OK_200.code()) .withReasonPhrase(OK_200.reasonPhrase()) .withHeaders( header(CONTENT_TYPE.toString(), MediaType.PNG.toString()), header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.png\"; filename=\"test.png\"") .withStatusCode(OK_200.code()) .withReasonPhrase(OK_200.reasonPhrase()) .withHeaders( header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.png\"; filename=\"test.png\""), header(CONTENT_TYPE.toString(), MediaType.PNG.toString()) .withStatusCode(OK_200.code()) .withReasonPhrase(OK_200.reasonPhrase()) .withHeaders( header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.png\"; filename=\"test.png\""), header(CONTENT_TYPE.toString(), MediaType.PNG.toString())
.withStatusCode(OK_200.code()) .withReasonPhrase(OK_200.reasonPhrase()) .withHeaders( header(CONTENT_TYPE.toString(), MediaType.PNG.toString()), header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.png\"; filename=\"test.png\"") .withStatusCode(OK_200.code()) .withReasonPhrase(OK_200.reasonPhrase()) .withHeaders( header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.png\"; filename=\"test.png\""), header(CONTENT_TYPE.toString(), MediaType.PNG.toString()) .withStatusCode(OK_200.code()) .withReasonPhrase(OK_200.reasonPhrase()) .withHeaders( header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.png\"; filename=\"test.png\""), header(CONTENT_TYPE.toString(), MediaType.PNG.toString())
.withStatusCode(OK_200.code()) .withReasonPhrase(OK_200.reasonPhrase()) .withHeaders( header(CONTENT_TYPE.toString(), MediaType.PDF.toString()), header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.pdf\"; filename=\"test.pdf\""), .withStatusCode(OK_200.code()) .withReasonPhrase(OK_200.reasonPhrase()) .withHeaders( header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.pdf\"; filename=\"test.pdf\""), header(CACHE_CONTROL.toString(), "must-revalidate, post-check=0, pre-check=0"), .withStatusCode(OK_200.code()) .withReasonPhrase(OK_200.reasonPhrase()) .withHeaders( header(CONTENT_DISPOSITION.toString(), "form-data; name=\"test.pdf\"; filename=\"test.pdf\""), header(CACHE_CONTROL.toString(), "must-revalidate, post-check=0, pre-check=0"),
.withHeaders( new Header(HttpHeaders.Names.CONTENT_TYPE,"application/json")
.withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase()) .withBody("some_body_response") .withHeaders(header("headerNameResponse", "headerValueResponse")) ); .withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase()) .withBody("some_body_response") .withHeaders( header("headerNameResponse", "headerValueResponse") ), .withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase()) .withBody("some_body_response") .withHeaders( header("headerNameResponse", "headerValueResponse") ),
.withStatusCode(HttpStatusCode.ACCEPTED_202.code()) .withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase()) .withHeaders( header("x-callback", "test_callback_header") .withStatusCode(HttpStatusCode.ACCEPTED_202.code()) .withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase()) .withHeaders( header("x-callback", "test_callback_header")
.withStatusCode(OK_200.code()) .withReasonPhrase(OK_200.reasonPhrase()) .withHeaders( header("x-test", "test_headers_and_body") .withStatusCode(OK_200.code()) .withReasonPhrase(OK_200.reasonPhrase()) .withHeaders( header("x-test", "test_headers_and_body")
.withStatusCode(OK_200.code()) .withReasonPhrase(OK_200.reasonPhrase()) .withHeaders( header("x-test", "test_headers_and_body") .withStatusCode(OK_200.code()) .withReasonPhrase(OK_200.reasonPhrase()) .withHeaders( header("x-test", "test_headers_and_body")
.withBody("some_body_response") .withCookies(cookie("cookieNameResponse", "cookieValueResponse")) .withHeaders( header(SET_COOKIE.toString(), "cookieNameResponse=cookieValueResponse") ), .withBody("some_body_response") .withCookies(cookie("cookieNameResponse", "cookieValueResponse")) .withHeaders( header(SET_COOKIE.toString(), "cookieNameResponse=cookieValueResponse") ),
.withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase()) .withBody("some_body_response") .withHeaders(header("headerNameResponse", "headerValueResponse")) .withCookies(cookie("cookieNameResponse", "cookieValueResponse")) );
.withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase()) .withBody("some_body_response") .withHeaders(header("headerNameResponse", "headerValueResponse")) .withCookies(cookie("cookieNameResponse", "cookieValueResponse")) );
.withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase()) .withBody("some_body_response") .withHeaders(header("headerNameResponse", "headerValueResponse")) .withCookies(cookie("cookieNameResponse", "cookieValueResponse")) );
.withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase()) .withBody("some_body") .withHeaders(header("headerName", "headerValue")) .withCookies(cookie("cookieName", "cookieValue")) );
.withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase()) .withBody("some_body") .withHeaders(header("headerName", "headerValue")) .withCookies(cookie("cookieName", "cookieValue")) );
.withReasonPhrase(HttpStatusCode.ACCEPTED_202.reasonPhrase()) .withBody("some_body") .withHeaders(header("headerName", "headerValue")) .withCookies(cookie("cookieName", "cookieValue")) );