Class WebSocketUtils
- java.lang.Object
-
- org.apache.cxf.transport.websocket.WebSocketUtils
-
public final class WebSocketUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringFLUSHED_KEYstatic StringMETHOD_KEYstatic StringSC_KEYstatic StringURI_KEY
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]buildHeaderLine(String name, String value)static byte[]buildRequest(String method, String url, Map<String,String> headers, byte[] data, int offset, int length)Build request bytes with the specified method, url, headers, and content entity.static byte[]buildResponse(byte[] headers, byte[] data, int offset, int length)Build response bytes with some generated headers.static byte[]buildResponse(byte[] data, int offset, int length)Build response bytes without status and type information.static byte[]buildResponse(Map<String,String> headers, byte[] data, int offset, int length)Build response bytes with the status and type information specified in the headers.static booleanisContainingCRLF(String value)static byte[]readBody(InputStream in)static Map<String,String>readHeaders(InputStream in)static Map<String,String>readHeaders(InputStream in, boolean req)Read header properties from the specified input stream.static StringreadLine(InputStream in)Read a line terminated by '\n' optionally preceded by '\r' from the specified input stream.
-
-
-
Field Detail
-
URI_KEY
public static final String URI_KEY
- See Also:
- Constant Field Values
-
METHOD_KEY
public static final String METHOD_KEY
- See Also:
- Constant Field Values
-
SC_KEY
public static final String SC_KEY
- See Also:
- Constant Field Values
-
FLUSHED_KEY
public static final String FLUSHED_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
readHeaders
public static Map<String,String> readHeaders(InputStream in, boolean req) throws IOException
Read header properties from the specified input stream. Only a restricted syntax is allowed as the syntax is in our control. Not allowed are: - multiline or line-wrapped headers are not not - charset other than utf-8. (although i would have preferred iso-8859-1 ;-)- Parameters:
in- the input streamreq- true if the input stream includes the request line- Returns:
- a map of name value pairs.
- Throws:
IOException
-
readHeaders
public static Map<String,String> readHeaders(InputStream in) throws IOException
- Throws:
IOException
-
readLine
public static String readLine(InputStream in) throws IOException
Read a line terminated by '\n' optionally preceded by '\r' from the specified input stream.- Parameters:
in- the input stream- Returns:
- Throws:
IOException
-
readBody
public static byte[] readBody(InputStream in) throws IOException
- Throws:
IOException
-
buildResponse
public static byte[] buildResponse(Map<String,String> headers, byte[] data, int offset, int length)
Build response bytes with the status and type information specified in the headers.- Parameters:
headers-data-offset-length-- Returns:
-
buildResponse
public static byte[] buildResponse(byte[] headers, byte[] data, int offset, int length)Build response bytes with some generated headers.- Parameters:
headers-data-offset-length-- Returns:
-
buildResponse
public static byte[] buildResponse(byte[] data, int offset, int length)Build response bytes without status and type information.- Parameters:
data-offset-length-- Returns:
-
buildRequest
public static byte[] buildRequest(String method, String url, Map<String,String> headers, byte[] data, int offset, int length)
Build request bytes with the specified method, url, headers, and content entity.- Parameters:
method-url-headers-data-offset-length-- Returns:
-
isContainingCRLF
public static boolean isContainingCRLF(String value)
-
-