Java Code Examples for org.springframework.http.HttpHeaders#readOnlyHttpHeaders()
The following examples show how to use
org.springframework.http.HttpHeaders#readOnlyHttpHeaders() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegistryAuthInterceptor.java From haven-platform with Apache License 2.0 | 6 votes |
@Override public ClientHttpResponse intercept(final HttpRequest request, final byte[] body, final ClientHttpRequestExecution execution) throws IOException { final HttpHeaders headers = request.getHeaders(); ClientHttpResponse execute = execution.execute(request, body); if (execute.getStatusCode() == HttpStatus.UNAUTHORIZED) { List<String> list = execute.getHeaders().get("Www-Authenticate"); if (!CollectionUtils.isEmpty(list)) { String tokenString = list.get(0); RegistryAuthAdapter.AuthContext ctx = new RegistryAuthAdapter.AuthContext(headers, HttpHeaders.readOnlyHttpHeaders(headers), tokenString); adapter.handle(ctx); return execution.execute(request, body); } } return execute; }
Example 2
Source File: StandardWebSocketSession.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Class constructor that associates a user with the WebSocket session. * * @param headers the headers of the handshake request * @param attributes attributes from the HTTP handshake to associate with the WebSocket session * @param localAddress the address on which the request was received * @param remoteAddress the address of the remote client * @param user the user associated with the session; if {@code null} we'll * fallback on the user available in the underlying WebSocket session */ public StandardWebSocketSession(HttpHeaders headers, Map<String, Object> attributes, InetSocketAddress localAddress, InetSocketAddress remoteAddress, Principal user) { super(attributes); headers = (headers != null) ? headers : new HttpHeaders(); this.handshakeHeaders = HttpHeaders.readOnlyHttpHeaders(headers); this.user = user; this.localAddress = localAddress; this.remoteAddress = remoteAddress; }
Example 3
Source File: DefaultServerResponseBuilder.java From java-technology-stack with MIT License | 5 votes |
protected AbstractServerResponse( int statusCode, HttpHeaders headers, MultiValueMap<String, ResponseCookie> cookies) { this.statusCode = statusCode; this.headers = HttpHeaders.readOnlyHttpHeaders(headers); this.cookies = CollectionUtils.unmodifiableMultiValueMap(new LinkedMultiValueMap<>(cookies)); }
Example 4
Source File: DefaultServerResponseBuilder.java From spring-analysis-note with MIT License | 5 votes |
protected AbstractServerResponse( int statusCode, HttpHeaders headers, MultiValueMap<String, ResponseCookie> cookies, Map<String, Object> hints) { this.statusCode = statusCode; this.headers = HttpHeaders.readOnlyHttpHeaders(headers); this.cookies = CollectionUtils.unmodifiableMultiValueMap(new LinkedMultiValueMap<>(cookies)); this.hints = hints; }
Example 5
Source File: JettyWebSocketSession.java From java-technology-stack with MIT License | 5 votes |
@Override public void initializeNativeSession(Session session) { super.initializeNativeSession(session); this.uri = session.getUpgradeRequest().getRequestURI(); HttpHeaders headers = new HttpHeaders(); headers.putAll(session.getUpgradeRequest().getHeaders()); this.headers = HttpHeaders.readOnlyHttpHeaders(headers); this.acceptedProtocol = session.getUpgradeResponse().getAcceptedSubProtocol(); List<ExtensionConfig> jettyExtensions = session.getUpgradeResponse().getExtensions(); if (!CollectionUtils.isEmpty(jettyExtensions)) { List<WebSocketExtension> extensions = new ArrayList<>(jettyExtensions.size()); for (ExtensionConfig jettyExtension : jettyExtensions) { extensions.add(new WebSocketExtension(jettyExtension.getName(), jettyExtension.getParameters())); } this.extensions = Collections.unmodifiableList(extensions); } else { this.extensions = Collections.emptyList(); } if (this.user == null) { this.user = session.getUpgradeRequest().getUserPrincipal(); } }
Example 6
Source File: JettyWebSocketSession.java From spring-analysis-note with MIT License | 5 votes |
@Override public void initializeNativeSession(Session session) { super.initializeNativeSession(session); this.uri = session.getUpgradeRequest().getRequestURI(); HttpHeaders headers = new HttpHeaders(); headers.putAll(session.getUpgradeRequest().getHeaders()); this.headers = HttpHeaders.readOnlyHttpHeaders(headers); this.acceptedProtocol = session.getUpgradeResponse().getAcceptedSubProtocol(); List<ExtensionConfig> jettyExtensions = session.getUpgradeResponse().getExtensions(); if (!CollectionUtils.isEmpty(jettyExtensions)) { List<WebSocketExtension> extensions = new ArrayList<>(jettyExtensions.size()); for (ExtensionConfig jettyExtension : jettyExtensions) { extensions.add(new WebSocketExtension(jettyExtension.getName(), jettyExtension.getParameters())); } this.extensions = Collections.unmodifiableList(extensions); } else { this.extensions = Collections.emptyList(); } if (this.user == null) { this.user = session.getUpgradeRequest().getUserPrincipal(); } }
Example 7
Source File: WebSocketHttpHeaders.java From spring-analysis-note with MIT License | 4 votes |
/** * Private constructor that can create read-only {@code WebSocketHttpHeader} instances. */ private WebSocketHttpHeaders(HttpHeaders headers, boolean readOnly) { this.headers = readOnly ? HttpHeaders.readOnlyHttpHeaders(headers) : headers; }
Example 8
Source File: ServletServerHttpResponse.java From spring-analysis-note with MIT License | 4 votes |
@Override public HttpHeaders getHeaders() { return (this.headersWritten ? HttpHeaders.readOnlyHttpHeaders(this.headers) : this.headers); }
Example 9
Source File: FormHttpMessageConverter.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public HttpHeaders getHeaders() { return (this.headersWritten ? HttpHeaders.readOnlyHttpHeaders(this.headers) : this.headers); }
Example 10
Source File: FormHttpMessageConverter.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public HttpHeaders getHeaders() { return (this.headersWritten ? HttpHeaders.readOnlyHttpHeaders(this.headers) : this.headers); }
Example 11
Source File: AbstractAsyncClientHttpRequest.java From spring-analysis-note with MIT License | 4 votes |
@Override public final HttpHeaders getHeaders() { return (this.executed ? HttpHeaders.readOnlyHttpHeaders(this.headers) : this.headers); }
Example 12
Source File: MockClientResponse.java From Hands-On-Reactive-Programming-in-Spring-5 with MIT License | 4 votes |
@Override public HttpHeaders asHttpHeaders() { return HttpHeaders.readOnlyHttpHeaders(delegate()); }
Example 13
Source File: MockServerRequest.java From java-technology-stack with MIT License | 4 votes |
@Override public HttpHeaders asHttpHeaders() { return HttpHeaders.readOnlyHttpHeaders(delegate()); }
Example 14
Source File: MockServerRequest.java From spring-analysis-note with MIT License | 4 votes |
@Override public HttpHeaders asHttpHeaders() { return HttpHeaders.readOnlyHttpHeaders(delegate()); }
Example 15
Source File: WebSocketHttpHeaders.java From java-technology-stack with MIT License | 4 votes |
/** * Private constructor that can create read-only {@code WebSocketHttpHeader} instances. */ private WebSocketHttpHeaders(HttpHeaders headers, boolean readOnly) { this.headers = readOnly ? HttpHeaders.readOnlyHttpHeaders(headers) : headers; }
Example 16
Source File: MultipartHttpMessageWriter.java From spring-analysis-note with MIT License | 4 votes |
@Override public HttpHeaders getHeaders() { return (this.body != null ? HttpHeaders.readOnlyHttpHeaders(this.headers) : this.headers); }
Example 17
Source File: ServletServerHttpResponse.java From java-technology-stack with MIT License | 4 votes |
@Override public HttpHeaders getHeaders() { return (this.headersWritten ? HttpHeaders.readOnlyHttpHeaders(this.headers) : this.headers); }
Example 18
Source File: RequestUtil.java From spring-batch-lightmin with Apache License 2.0 | 4 votes |
public static <T> HttpEntity<T> createApplicationJsonEntity(final T body) { final HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON); headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); return new HttpEntity<>(body, HttpHeaders.readOnlyHttpHeaders(headers)); }
Example 19
Source File: DefaultWebClientBuilder.java From java-technology-stack with MIT License | 4 votes |
private static HttpHeaders unmodifiableCopy(HttpHeaders headers) { return HttpHeaders.readOnlyHttpHeaders(headers); }
Example 20
Source File: AbstractAsyncClientHttpRequest.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public final HttpHeaders getHeaders() { return (this.executed ? HttpHeaders.readOnlyHttpHeaders(this.headers) : this.headers); }