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