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;
020
021import org.springframework.http.HttpHeaders;
022
023/**
024 * A component that can execute the SockJS "Info" request that needs to be
025 * performed before the SockJS session starts in order to check server endpoint
026 * capabilities such as whether the endpoint permits use of WebSocket.
027 *
028 * <p>Typically {@link XhrTransport} implementations are also implementations
029 * of this contract.
030 *
031 * @author Rossen Stoyanchev
032 * @since 4.1
033 * @see AbstractXhrTransport
034 */
035public interface InfoReceiver {
036
037        /**
038         * Perform an HTTP request to the SockJS "Info" URL.
039         * and return the resulting JSON response content, or raise an exception.
040         * <p>Note that as of 4.2 this method accepts a {@code headers} parameter.
041         * @param infoUrl the URL to obtain SockJS server information from
042         * @param headers the headers to use for the request
043         * @return the body of the response
044         */
045        String executeInfoRequest(URI infoUrl, HttpHeaders headers);
046
047}