本文整理了Java中org.jboss.netty.handler.codec.http.HttpRequest.headers()
方法的一些代码示例,展示了HttpRequest.headers()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.headers()
方法的具体详情如下:
包路径:org.jboss.netty.handler.codec.http.HttpRequest
类名称:HttpRequest
方法名:headers
暂无
代码示例来源:origin: io.netty/netty
/**
* Check if the given request is a multipart request
*
* @return True if the request is a Multipart request
*/
public static boolean isMultipart(HttpRequest request) throws ErrorDataDecoderException {
if (request.headers().contains(HttpHeaders.Names.CONTENT_TYPE)) {
return getMultipartDataBoundary(request.headers().get(HttpHeaders.Names.CONTENT_TYPE)) != null;
} else {
return false;
}
}
代码示例来源:origin: io.netty/netty
private static String getWebSocketLocation(ChannelPipeline cp, HttpRequest req, String path) {
String protocol = "ws";
if (cp.get(SslHandler.class) != null) {
// SSL in use so use Secure WebSockets
protocol = "wss";
}
return protocol + "://" + req.headers().get(HttpHeaders.Names.HOST) + path;
}
代码示例来源:origin: apache/hive
request.headers().get(SecureShuffleUtils.HTTP_HEADER_URL_HASH);
if (urlHashStr == null) {
LOG.info("Missing header hash for " + appid);
代码示例来源:origin: io.netty/netty
/**
*
* @param factory the factory used to create InterfaceHttpData
* @param request the request to decode
* @param charset the charset to use as default
* @throws NullPointerException for request or charset or factory
* @throws ErrorDataDecoderException if the default charset was wrong when decoding or other errors
*/
public HttpPostMultipartRequestDecoder(HttpDataFactory factory, HttpRequest request,
Charset charset) throws ErrorDataDecoderException {
if (factory == null) {
throw new NullPointerException("factory");
}
if (request == null) {
throw new NullPointerException("request");
}
if (charset == null) {
throw new NullPointerException("charset");
}
this.request = request;
this.charset = charset;
this.factory = factory;
// Fill default values
setMultipart(this.request.headers().get(HttpHeaders.Names.CONTENT_TYPE));
if (!this.request.isChunked()) {
undecodedChunk = this.request.getContent();
isLastChunk = true;
parseBody();
}
}
代码示例来源:origin: io.netty/netty
request.headers().add(Names.UPGRADE, Values.WEBSOCKET.toLowerCase());
request.headers().add(Names.CONNECTION, Values.UPGRADE);
request.headers().add(Names.SEC_WEBSOCKET_KEY, key);
request.headers().add(Names.HOST, wsURL.getHost());
request.headers().add(Names.SEC_WEBSOCKET_ORIGIN, originValue);
request.headers().add(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
request.headers().add(Names.SEC_WEBSOCKET_VERSION, "7");
request.headers().add(e.getKey(), e.getValue());
代码示例来源:origin: io.netty/netty
request.headers().add(Names.UPGRADE, Values.WEBSOCKET.toLowerCase());
request.headers().add(Names.CONNECTION, Values.UPGRADE);
request.headers().add(Names.SEC_WEBSOCKET_KEY, key);
request.headers().add(Names.HOST, wsURL.getHost() + ':' + wsPort);
request.headers().add(Names.ORIGIN, originValue);
request.headers().add(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
request.headers().add(Names.SEC_WEBSOCKET_VERSION, "13");
request.headers().add(e.getKey(), e.getValue());
代码示例来源:origin: io.netty/netty
request.headers().add(Names.UPGRADE, Values.WEBSOCKET.toLowerCase());
request.headers().add(Names.CONNECTION, Values.UPGRADE);
request.headers().add(Names.SEC_WEBSOCKET_KEY, key);
request.headers().add(Names.HOST, wsURL.getHost());
request.headers().add(Names.SEC_WEBSOCKET_ORIGIN, originValue);
request.headers().add(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
request.headers().add(Names.SEC_WEBSOCKET_VERSION, "8");
request.headers().add(e.getKey(), e.getValue());
代码示例来源:origin: io.netty/netty
request.headers().add(Names.UPGRADE, Values.WEBSOCKET);
request.headers().add(Names.CONNECTION, Values.UPGRADE);
request.headers().add(Names.HOST, wsURL.getHost());
request.headers().add(Names.ORIGIN, originValue);
request.headers().add(Names.SEC_WEBSOCKET_KEY1, key1);
request.headers().add(Names.SEC_WEBSOCKET_KEY2, key2);
String expectedSubprotocol = getExpectedSubprotocol();
if (expectedSubprotocol != null && expectedSubprotocol.length() != 0) {
request.headers().add(Names.SEC_WEBSOCKET_PROTOCOL, expectedSubprotocol);
request.headers().add(e.getKey(), e.getValue());
request.headers().set(Names.CONTENT_LENGTH, key3.length);
request.setContent(ChannelBuffers.copiedBuffer(key3));
代码示例来源:origin: io.netty/netty
/**
* Instances a new handshaker
*
* @return A new WebSocketServerHandshaker for the requested web socket version. Null if web
* socket version is not supported.
*/
public WebSocketServerHandshaker newHandshaker(HttpRequest req) {
String version = req.headers().get(Names.SEC_WEBSOCKET_VERSION);
if (version != null) {
if (version.equals(WebSocketVersion.V13.toHttpHeaderValue())) {
// Version 13 of the wire protocol - RFC 6455 (version 17 of the draft hybi specification).
return new WebSocketServerHandshaker13(
webSocketURL, subprotocols, allowExtensions, maxFramePayloadLength);
} else if (version.equals(WebSocketVersion.V08.toHttpHeaderValue())) {
// Version 8 of the wire protocol - version 10 of the draft hybi specification.
return new WebSocketServerHandshaker08(
webSocketURL, subprotocols, allowExtensions, maxFramePayloadLength);
} else if (version.equals(WebSocketVersion.V07.toHttpHeaderValue())) {
// Version 8 of the wire protocol - version 07 of the draft hybi specification.
return new WebSocketServerHandshaker07(
webSocketURL, subprotocols, allowExtensions, maxFramePayloadLength);
} else {
return null;
}
} else {
// Assume version 00 where version header was not specified
return new WebSocketServerHandshaker00(
webSocketURL, subprotocols, maxFramePayloadLength);
}
}
代码示例来源:origin: apache/hive
request.headers().get(ShuffleHeader.HTTP_HEADER_NAME))
|| !ShuffleHeader.DEFAULT_HTTP_HEADER_VERSION.equals(
request.headers().get(ShuffleHeader.HTTP_HEADER_VERSION))) {
sendError(ctx, "Incompatible shuffle request version", BAD_REQUEST);
代码示例来源:origin: io.netty/netty
HttpVersion.HTTP_1_1, HttpMethod.POST, serverPath);
if (serverName != null) {
req.headers().set(HttpHeaders.Names.HOST, serverName);
req.headers().set(HttpHeaders.Names.CONTENT_TYPE, "application/octet-stream");
req.headers().set(HttpHeaders.Names.TRANSFER_ENCODING, HttpHeaders.Values.CHUNKED);
req.headers().set(HttpHeaders.Names.CONTENT_TRANSFER_ENCODING, HttpHeaders.Values.BINARY);
req.headers().set(HttpHeaders.Names.USER_AGENT, HttpTunnelingClientSocketChannel.class.getName());
代码示例来源:origin: io.netty/netty
private static HttpRequest createHttpRequest(int spdyVersion, SpdyHeadersFrame requestFrame)
throws Exception {
// Create the first line of the request from the name/value pairs
HttpMethod method = SpdyHeaders.getMethod(spdyVersion, requestFrame);
String url = SpdyHeaders.getUrl(spdyVersion, requestFrame);
HttpVersion httpVersion = SpdyHeaders.getVersion(spdyVersion, requestFrame);
SpdyHeaders.removeMethod(spdyVersion, requestFrame);
SpdyHeaders.removeUrl(spdyVersion, requestFrame);
SpdyHeaders.removeVersion(spdyVersion, requestFrame);
HttpRequest httpRequest = new DefaultHttpRequest(httpVersion, method, url);
// Remove the scheme header
SpdyHeaders.removeScheme(spdyVersion, requestFrame);
// Replace the SPDY host header with the HTTP host header
String host = SpdyHeaders.getHost(requestFrame);
SpdyHeaders.removeHost(requestFrame);
HttpHeaders.setHost(httpRequest, host);
for (Map.Entry<String, String> e: requestFrame.headers()) {
httpRequest.headers().add(e.getKey(), e.getValue());
}
// The Connection and Keep-Alive headers are no longer valid
HttpHeaders.setKeepAlive(httpRequest, true);
// Transfer-Encoding header is not valid
httpRequest.headers().remove(HttpHeaders.Names.TRANSFER_ENCODING);
return httpRequest;
}
代码示例来源:origin: io.netty/netty
if (!Values.UPGRADE.equalsIgnoreCase(req.headers().get(CONNECTION))
|| !WEBSOCKET.equalsIgnoreCase(req.headers().get(Names.UPGRADE))) {
throw new WebSocketHandshakeException("not a WebSocket handshake request: missing upgrade");
boolean isHixie76 = req.headers().contains(SEC_WEBSOCKET_KEY1) && req.headers().contains(SEC_WEBSOCKET_KEY2);
res.headers().add(SEC_WEBSOCKET_ORIGIN, req.headers().get(ORIGIN));
res.headers().add(SEC_WEBSOCKET_LOCATION, getWebSocketUrl());
String subprotocols = req.headers().get(SEC_WEBSOCKET_PROTOCOL);
if (subprotocols != null) {
String selectedSubprotocol = selectSubprotocol(subprotocols);
String key1 = req.headers().get(SEC_WEBSOCKET_KEY1);
String key2 = req.headers().get(SEC_WEBSOCKET_KEY2);
int a = (int) (Long.parseLong(key1.replaceAll("[^0-9]", "")) / key1.replaceAll("[^ ]", "").length());
int b = (int) (Long.parseLong(key2.replaceAll("[^0-9]", "")) / key2.replaceAll("[^ ]", "").length());
} else {
res.headers().add(WEBSOCKET_ORIGIN, req.headers().get(ORIGIN));
res.headers().add(WEBSOCKET_LOCATION, getWebSocketUrl());
String protocol = req.headers().get(WEBSOCKET_PROTOCOL);
if (protocol != null) {
res.headers().add(WEBSOCKET_PROTOCOL, selectSubprotocol(protocol));
代码示例来源:origin: apache/incubator-druid
httpRequest.headers().add(HttpHeaders.Names.HOST, getHost(url));
httpRequest.headers().set(HttpHeaders.Names.ACCEPT_ENCODING, compressionCodec.getEncodingString());
httpRequest.headers().add(key, obj);
代码示例来源:origin: io.netty/netty
HttpHeaders headers = request.headers();
代码示例来源:origin: io.netty/netty
String key = req.headers().get(Names.SEC_WEBSOCKET_KEY);
if (key == null) {
throw new WebSocketHandshakeException("not a WebSocket request: missing key");
res.headers().add(Names.CONNECTION, Names.UPGRADE);
res.headers().add(Names.SEC_WEBSOCKET_ACCEPT, accept);
String subprotocols = req.headers().get(Names.SEC_WEBSOCKET_PROTOCOL);
if (subprotocols != null) {
String selectedSubprotocol = selectSubprotocol(subprotocols);
代码示例来源:origin: io.netty/netty
String key = req.headers().get(Names.SEC_WEBSOCKET_KEY);
if (key == null) {
throw new WebSocketHandshakeException("not a WebSocket request: missing key");
res.headers().add(Names.CONNECTION, Names.UPGRADE);
res.headers().add(Names.SEC_WEBSOCKET_ACCEPT, accept);
String subprotocols = req.headers().get(Names.SEC_WEBSOCKET_PROTOCOL);
if (subprotocols != null) {
String selectedSubprotocol = selectSubprotocol(subprotocols);
代码示例来源:origin: io.netty/netty
String key = req.headers().get(Names.SEC_WEBSOCKET_KEY);
if (key == null) {
throw new WebSocketHandshakeException("not a WebSocket request: missing key");
res.headers().add(Names.CONNECTION, Names.UPGRADE);
res.headers().add(Names.SEC_WEBSOCKET_ACCEPT, accept);
String subprotocols = req.headers().get(Names.SEC_WEBSOCKET_PROTOCOL);
if (subprotocols != null) {
String selectedSubprotocol = selectSubprotocol(subprotocols);
代码示例来源:origin: resteasy/Resteasy
public static MultivaluedMap<String, String> extractRequestHeaders(HttpRequest request)
{
Headers<String> requestHeaders = new Headers<String>();
for (Map.Entry<String, String> header : request.headers())
{
requestHeaders.add(header.getKey(), header.getValue());
}
return requestHeaders;
}
}
代码示例来源:origin: com.ning/async-http-client
private void configureTransferAdapter(AsyncHandler<?> handler, HttpRequest httpRequest) {
FluentCaseInsensitiveStringsMap h = new FluentCaseInsensitiveStringsMap();
for (Map.Entry<String, String> entries : httpRequest.headers()) {
h.add(entries.getKey(), entries.getValue());
}
TransferCompletionHandler.class.cast(handler).headers(h);
}
内容来源于网络,如有侵权,请联系作者删除!