001/* 002 * Copyright 2002-2015 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.web.socket.sockjs.client; 018 019import java.net.URI; 020import java.security.Principal; 021 022import org.springframework.http.HttpHeaders; 023import org.springframework.web.socket.sockjs.frame.SockJsMessageCodec; 024 025/** 026 * Exposes information, typically to {@link Transport} and 027 * {@link AbstractClientSockJsSession session} implementations, about a request 028 * to connect to a SockJS server endpoint over a given transport. 029 * 030 * <p>Note that a single request to connect via {@link SockJsClient} may result 031 * in multiple instances of {@link TransportRequest}, one for each transport 032 * before a connection is successfully established. 033 * 034 * @author Rossen Stoyanchev 035 * @since 4.1 036 */ 037public interface TransportRequest { 038 039 /** 040 * Return information about the SockJS URL including server and session ID. 041 */ 042 SockJsUrlInfo getSockJsUrlInfo(); 043 044 /** 045 * Return the headers to send with the connect request. 046 */ 047 HttpHeaders getHandshakeHeaders(); 048 049 /** 050 * Return the headers to add to all other HTTP requests besides the handshake 051 * request such as XHR receive and send requests. 052 * @since 4.2 053 */ 054 HttpHeaders getHttpRequestHeaders(); 055 056 /** 057 * Return the transport URL for the given transport. 058 * <p>For an {@link XhrTransport} this is the URL for receiving messages. 059 */ 060 URI getTransportUrl(); 061 062 /** 063 * Return the user associated with the request, if any. 064 */ 065 Principal getUser(); 066 067 /** 068 * Return the message codec to use for encoding SockJS messages. 069 */ 070 SockJsMessageCodec getMessageCodec(); 071 072 /** 073 * Register a timeout cleanup task to invoke if the SockJS session is not 074 * fully established within the calculated retransmission timeout period. 075 */ 076 void addTimeoutTask(Runnable runnable); 077 078}