org.springframework.web.socket.WebSocketHttpHeaders.set()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(207)

本文整理了Java中org.springframework.web.socket.WebSocketHttpHeaders.set()方法的一些代码示例,展示了WebSocketHttpHeaders.set()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebSocketHttpHeaders.set()方法的具体详情如下:
包路径:org.springframework.web.socket.WebSocketHttpHeaders
类名称:WebSocketHttpHeaders
方法名:set

WebSocketHttpHeaders.set介绍

[英]Set the given, single header value under the given name.
[中]

代码示例

代码示例来源:origin: spring-projects/spring-framework

  1. /**
  2. * Sets the (new) value of the {@code Sec-WebSocket-Protocol} header.
  3. * @param secWebSocketProtocol the value of the header
  4. */
  5. public void setSecWebSocketProtocol(String secWebSocketProtocol) {
  6. set(SEC_WEBSOCKET_PROTOCOL, secWebSocketProtocol);
  7. }

代码示例来源:origin: spring-projects/spring-framework

  1. /**
  2. * Sets the (new) value of the {@code Sec-WebSocket-Accept} header.
  3. * @param secWebSocketAccept the value of the header
  4. */
  5. public void setSecWebSocketAccept(@Nullable String secWebSocketAccept) {
  6. set(SEC_WEBSOCKET_ACCEPT, secWebSocketAccept);
  7. }

代码示例来源:origin: spring-projects/spring-framework

  1. /**
  2. * Sets the (new) value of the {@code Sec-WebSocket-Key} header.
  3. * @param secWebSocketKey the value of the header
  4. */
  5. public void setSecWebSocketKey(@Nullable String secWebSocketKey) {
  6. set(SEC_WEBSOCKET_KEY, secWebSocketKey);
  7. }

代码示例来源:origin: spring-projects/spring-framework

  1. /**
  2. * Sets the (new) value of the {@code Sec-WebSocket-Version} header.
  3. * @param secWebSocketVersion the value of the header
  4. */
  5. public void setSecWebSocketVersion(@Nullable String secWebSocketVersion) {
  6. set(SEC_WEBSOCKET_VERSION, secWebSocketVersion);
  7. }

代码示例来源:origin: spring-projects/spring-framework

  1. /**
  2. * Sets the (new) value of the {@code Sec-WebSocket-Protocol} header.
  3. * @param secWebSocketProtocols the value of the header
  4. */
  5. public void setSecWebSocketProtocol(List<String> secWebSocketProtocols) {
  6. set(SEC_WEBSOCKET_PROTOCOL, toCommaDelimitedString(secWebSocketProtocols));
  7. }

代码示例来源:origin: spring-projects/spring-framework

  1. /**
  2. * Sets the (new) value(s) of the {@code Sec-WebSocket-Extensions} header.
  3. * @param extensions the values for the header
  4. */
  5. public void setSecWebSocketExtensions(List<WebSocketExtension> extensions) {
  6. List<String> result = new ArrayList<>(extensions.size());
  7. for (WebSocketExtension extension : extensions) {
  8. result.add(extension.toString());
  9. }
  10. set(SEC_WEBSOCKET_EXTENSIONS, toCommaDelimitedString(result));
  11. }

代码示例来源:origin: spring-projects/spring-framework

  1. @Test
  2. public void connectAndUseSubsetOfHandshakeHeadersForHttpRequests() throws Exception {
  3. ArgumentCaptor<HttpHeaders> headersCaptor = setupInfoRequest(false);
  4. this.xhrTransport.setStreamingDisabled(true);
  5. WebSocketHttpHeaders headers = new WebSocketHttpHeaders();
  6. headers.set("foo", "bar");
  7. headers.set("auth", "123");
  8. this.sockJsClient.setHttpHeaderNames("auth");
  9. this.sockJsClient.doHandshake(handler, headers, new URI(URL)).addCallback(this.connectCallback);
  10. assertEquals(1, headersCaptor.getValue().size());
  11. assertEquals("123", headersCaptor.getValue().getFirst("auth"));
  12. assertEquals(1, this.xhrTransport.getRequest().getHttpRequestHeaders().size());
  13. assertEquals("123", this.xhrTransport.getRequest().getHttpRequestHeaders().getFirst("auth"));
  14. }

代码示例来源:origin: spring-projects/spring-framework

  1. @Test
  2. public void connectWithHandshakeHeaders() throws Exception {
  3. ArgumentCaptor<HttpHeaders> headersCaptor = setupInfoRequest(false);
  4. this.xhrTransport.setStreamingDisabled(true);
  5. WebSocketHttpHeaders headers = new WebSocketHttpHeaders();
  6. headers.set("foo", "bar");
  7. headers.set("auth", "123");
  8. this.sockJsClient.doHandshake(handler, headers, new URI(URL)).addCallback(this.connectCallback);
  9. HttpHeaders httpHeaders = headersCaptor.getValue();
  10. assertEquals(2, httpHeaders.size());
  11. assertEquals("bar", httpHeaders.getFirst("foo"));
  12. assertEquals("123", httpHeaders.getFirst("auth"));
  13. httpHeaders = this.xhrTransport.getRequest().getHttpRequestHeaders();
  14. assertEquals(2, httpHeaders.size());
  15. assertEquals("bar", httpHeaders.getFirst("foo"));
  16. assertEquals("123", httpHeaders.getFirst("auth"));
  17. }

代码示例来源:origin: org.springframework/spring-websocket

  1. /**
  2. * Sets the (new) value of the {@code Sec-WebSocket-Protocol} header.
  3. * @param secWebSocketProtocol the value of the header
  4. */
  5. public void setSecWebSocketProtocol(String secWebSocketProtocol) {
  6. set(SEC_WEBSOCKET_PROTOCOL, secWebSocketProtocol);
  7. }

代码示例来源:origin: apache/servicemix-bundles

  1. /**
  2. * Sets the (new) value of the {@code Sec-WebSocket-Protocol} header.
  3. * @param secWebSocketProtocol the value of the header
  4. */
  5. public void setSecWebSocketProtocol(String secWebSocketProtocol) {
  6. set(SEC_WEBSOCKET_PROTOCOL, secWebSocketProtocol);
  7. }

代码示例来源:origin: org.springframework/spring-websocket

  1. /**
  2. * Sets the (new) value of the {@code Sec-WebSocket-Version} header.
  3. * @param secWebSocketVersion the value of the header
  4. */
  5. public void setSecWebSocketVersion(@Nullable String secWebSocketVersion) {
  6. set(SEC_WEBSOCKET_VERSION, secWebSocketVersion);
  7. }

代码示例来源:origin: org.springframework/spring-websocket

  1. /**
  2. * Sets the (new) value of the {@code Sec-WebSocket-Key} header.
  3. * @param secWebSocketKey the value of the header
  4. */
  5. public void setSecWebSocketKey(@Nullable String secWebSocketKey) {
  6. set(SEC_WEBSOCKET_KEY, secWebSocketKey);
  7. }

代码示例来源:origin: org.springframework/spring-websocket

  1. /**
  2. * Sets the (new) value of the {@code Sec-WebSocket-Accept} header.
  3. * @param secWebSocketAccept the value of the header
  4. */
  5. public void setSecWebSocketAccept(@Nullable String secWebSocketAccept) {
  6. set(SEC_WEBSOCKET_ACCEPT, secWebSocketAccept);
  7. }

代码示例来源:origin: apache/servicemix-bundles

  1. /**
  2. * Sets the (new) value of the {@code Sec-WebSocket-Key} header.
  3. * @param secWebSocketKey the value of the header
  4. */
  5. public void setSecWebSocketKey(@Nullable String secWebSocketKey) {
  6. set(SEC_WEBSOCKET_KEY, secWebSocketKey);
  7. }

代码示例来源:origin: apache/servicemix-bundles

  1. /**
  2. * Sets the (new) value of the {@code Sec-WebSocket-Version} header.
  3. * @param secWebSocketVersion the value of the header
  4. */
  5. public void setSecWebSocketVersion(@Nullable String secWebSocketVersion) {
  6. set(SEC_WEBSOCKET_VERSION, secWebSocketVersion);
  7. }

代码示例来源:origin: apache/servicemix-bundles

  1. /**
  2. * Sets the (new) value of the {@code Sec-WebSocket-Accept} header.
  3. * @param secWebSocketAccept the value of the header
  4. */
  5. public void setSecWebSocketAccept(@Nullable String secWebSocketAccept) {
  6. set(SEC_WEBSOCKET_ACCEPT, secWebSocketAccept);
  7. }

代码示例来源:origin: org.springframework/spring-websocket

  1. /**
  2. * Sets the (new) value of the {@code Sec-WebSocket-Protocol} header.
  3. * @param secWebSocketProtocols the value of the header
  4. */
  5. public void setSecWebSocketProtocol(List<String> secWebSocketProtocols) {
  6. set(SEC_WEBSOCKET_PROTOCOL, toCommaDelimitedString(secWebSocketProtocols));
  7. }

代码示例来源:origin: apache/servicemix-bundles

  1. /**
  2. * Sets the (new) value of the {@code Sec-WebSocket-Protocol} header.
  3. * @param secWebSocketProtocols the value of the header
  4. */
  5. public void setSecWebSocketProtocol(List<String> secWebSocketProtocols) {
  6. set(SEC_WEBSOCKET_PROTOCOL, toCommaDelimitedString(secWebSocketProtocols));
  7. }

代码示例来源:origin: org.springframework/spring-websocket

  1. /**
  2. * Sets the (new) value(s) of the {@code Sec-WebSocket-Extensions} header.
  3. * @param extensions the values for the header
  4. */
  5. public void setSecWebSocketExtensions(List<WebSocketExtension> extensions) {
  6. List<String> result = new ArrayList<>(extensions.size());
  7. for (WebSocketExtension extension : extensions) {
  8. result.add(extension.toString());
  9. }
  10. set(SEC_WEBSOCKET_EXTENSIONS, toCommaDelimitedString(result));
  11. }

代码示例来源:origin: apache/servicemix-bundles

  1. /**
  2. * Sets the (new) value(s) of the {@code Sec-WebSocket-Extensions} header.
  3. * @param extensions the values for the header
  4. */
  5. public void setSecWebSocketExtensions(List<WebSocketExtension> extensions) {
  6. List<String> result = new ArrayList<>(extensions.size());
  7. for (WebSocketExtension extension : extensions) {
  8. result.add(extension.toString());
  9. }
  10. set(SEC_WEBSOCKET_EXTENSIONS, toCommaDelimitedString(result));
  11. }

相关文章