/** * Copy all given headers. */ public DefaultResponseCreator headers(HttpHeaders headers) { this.headers.putAll(headers); return this; }
@Override public RenderingResponse.Builder headers(HttpHeaders headers) { this.headers.putAll(headers); return this; }
@Override public EntityResponse.Builder<T> headers(HttpHeaders headers) { this.headers.putAll(headers); return this; }
@Override public BodyBuilder headers(MultiValueMap<String, String> headers) { this.headers.putAll(headers); return this; }
@Override public void putAll(Map<? extends String, ? extends List<String>> m) { this.headers.putAll(m); }
@Override public BodyBuilder headers(@Nullable HttpHeaders headers) { if (headers != null) { this.headers.putAll(headers); } return this; }
private HttpHeaders initHeaders() { if (CollectionUtils.isEmpty(this.headers)) { return (defaultHeaders != null ? defaultHeaders : new HttpHeaders()); } else if (CollectionUtils.isEmpty(defaultHeaders)) { return this.headers; } else { HttpHeaders result = new HttpHeaders(); result.putAll(defaultHeaders); result.putAll(this.headers); return result; } }
private void writeHeaders() { if (this.headersWritten) { return; } this.headersWritten = true; this.writtenHeaders.putAll(this.headers); }
@Override public DefaultRenderingBuilder headers(HttpHeaders headers) { initHeaders().putAll(headers); return this; }
@Override public BodyBuilder headers(MultiValueMap<String, String> headers) { this.headers.putAll(headers); return this; }
public StreamingServletServerHttpResponse(ServerHttpResponse delegate) { this.delegate = delegate; this.mutableHeaders.putAll(delegate.getHeaders()); }
/** * Create a new {@code HttpEntity} with the given body and headers. * @param body the entity body * @param headers the entity headers */ public HttpEntity(@Nullable T body, @Nullable MultiValueMap<String, String> headers) { this.body = body; HttpHeaders tempHeaders = new HttpHeaders(); if (headers != null) { tempHeaders.putAll(headers); } this.headers = HttpHeaders.readOnlyHttpHeaders(tempHeaders); }
@Override public void onPartFinished(StreamStorage storage, Map<String, List<String>> headers) { HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.putAll(headers); this.sink.next(createPart(storage, httpHeaders)); }
public XhrClientSockJsSession(TransportRequest request, WebSocketHandler handler, XhrTransport transport, SettableListenableFuture<WebSocketSession> connectFuture) { super(request, handler, connectFuture); Assert.notNull(transport, "XhrTransport is required"); this.transport = transport; this.headers = request.getHttpRequestHeaders(); this.sendHeaders = new HttpHeaders(); this.sendHeaders.putAll(this.headers); this.sendHeaders.setContentType(MediaType.APPLICATION_JSON); this.sendUrl = request.getSockJsUrlInfo().getTransportUrl(TransportType.XHR_SEND); }
@Override public ClientHttpResponse createResponse(@Nullable ClientHttpRequest request) throws IOException { MockClientHttpResponse response; if (this.contentResource != null) { InputStream stream = this.contentResource.getInputStream(); response = new MockClientHttpResponse(stream, this.statusCode); } else { response = new MockClientHttpResponse(this.content, this.statusCode); } response.getHeaders().putAll(this.headers); return response; }
public DefaultRenderingResponseBuilder(RenderingResponse other) { Assert.notNull(other, "RenderingResponse must not be null"); this.name = other.name(); this.status = (other instanceof DefaultRenderingResponse ? ((DefaultRenderingResponse) other).statusCode : other.statusCode().value()); this.headers.putAll(other.headers()); this.model.putAll(other.model()); }
@Override public void doWithRequest(ClientHttpRequest request) throws IOException { request.getHeaders().putAll(this.headers); if (this.body != null) { StreamUtils.copy(this.body, SockJsFrame.CHARSET, request.getBody()); } } }
private ClientHttpResponse adaptResponse(MockServerHttpResponse response, Flux<DataBuffer> body) { HttpStatus status = Optional.ofNullable(response.getStatusCode()).orElse(HttpStatus.OK); MockClientHttpResponse clientResponse = new MockClientHttpResponse(status); clientResponse.getHeaders().putAll(response.getHeaders()); clientResponse.getCookies().putAll(response.getCookies()); clientResponse.setBody(body); return clientResponse; }
@Override protected ClientHttpResponse executeInternal(HttpHeaders headers, byte[] bufferedOutput) throws IOException { this.request.getHeaders().putAll(headers); StreamUtils.copy(bufferedOutput, this.request.getBody()); ClientHttpResponse response = this.request.execute(); return new BufferingClientHttpResponseWrapper(response); }
private HeaderAssertions headerAssertions(HttpHeaders responseHeaders) { MockClientHttpRequest request = new MockClientHttpRequest(HttpMethod.GET, URI.create("/")); MockClientHttpResponse response = new MockClientHttpResponse(HttpStatus.OK); response.getHeaders().putAll(responseHeaders); MonoProcessor<byte[]> emptyContent = MonoProcessor.create(); emptyContent.onComplete(); ExchangeResult result = new ExchangeResult(request, response, emptyContent, emptyContent, Duration.ZERO, null); return new HeaderAssertions(result, mock(WebTestClient.ResponseSpec.class)); }