本文整理匯總了Java中org.jboss.netty.handler.codec.http.HttpRequest.getHeaders方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpRequest.getHeaders方法的具體用法?Java HttpRequest.getHeaders怎麽用?Java HttpRequest.getHeaders使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.jboss.netty.handler.codec.http.HttpRequest
的用法示例。
在下文中一共展示了HttpRequest.getHeaders方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: decode
import org.jboss.netty.handler.codec.http.HttpRequest; //導入方法依賴的package包/類
@Override
protected Object decode(ChannelHandlerContext ctx, Channel channel, Object msg)
throws Exception
{
HttpRequest nettyRequest = (HttpRequest) msg;
URI uri = new URI(nettyRequest.getUri());
RestRequestBuilder builder = new RestRequestBuilder(uri);
builder.setMethod(nettyRequest.getMethod().getName());
for (Map.Entry<String, String> e : nettyRequest.getHeaders())
{
builder.unsafeAddHeaderValue(e.getKey(), e.getValue());
}
ChannelBuffer buf = nettyRequest.getContent();
if (buf != null)
{
if (buf.hasArray())
{
// TODO make a copy?
builder.setEntity(buf.array());
}
}
return builder.build();
}
示例2: messageReceived
import org.jboss.netty.handler.codec.http.HttpRequest; //導入方法依賴的package包/類
@Override
public void messageReceived(final ChannelHandlerContext ctx, final MessageEvent evt)
throws Exception
{ //[id: 0x42320e48, /192.168.20.58:60810 => /192.168.20.128:5000] RECEIVED: DefaultHttpRequest(chunked: false) OPTIONS * RTSP/1.0 CSeq: 0 X-Apple-Device-ID: 0xf0c1f145b120 Apple-Challenge: aegvjDkBxWjPQlDBfGZnXA== DACP-ID: D3DADC2D4FD6B073 Active-Remote: 850148892 User-Agent: AirPlay/190.9
final HttpRequest req = (HttpRequest)evt.getMessage();
LogManager.i("====================messageReceived:"+req.toString());
final Level level = Level.FINE;
// if (Constants.DEBUG) {
final String content = req.getContent().toString(Charset.defaultCharset());
final StringBuilder s = new StringBuilder();
s.append(">");
s.append(req.getMethod());
s.append(" ");
s.append(req.getUri());
s.append("\n");
OUT:for(final Map.Entry<String, String> header: req.getHeaders()) {
s.append(" ");
s.append(header.getKey());
s.append(": ");
s.append(header.getValue());
s.append("\n");
if("Active-Remote".equalsIgnoreCase(header.getKey())){
remote = "Active-Remote: "+header.getValue() ;
LogManager.e("remote============"+remote);
break OUT ;
}
}
s.append(content);
// LogManager.i("messageReceived:"+s.toString());
// }
super.messageReceived(ctx, evt);
}
示例3: dump
import org.jboss.netty.handler.codec.http.HttpRequest; //導入方法依賴的package包/類
private void dump(HttpRequest request) {
if (!this.logger.isDebugEnabled()) {
return;
}
this.logger.debug(request.getMethod().getName());
this.logger.debug(request.getUri());
for (Entry<String, String> h : request.getHeaders()) {
this.logger.debug("%s=%s", h.getKey(), h.getValue());
}
}
示例4: renderServerChannelContext
import org.jboss.netty.handler.codec.http.HttpRequest; //導入方法依賴的package包/類
private void renderServerChannelContext(HttpRequest request) {
ServerChannelSender serverChannelSender = (WebSocketServerChannelSender) this.sender;
for (Entry<String, String> h : request.getHeaders()) {
serverChannelSender.setContext(h.getKey(), h.getValue());
}
}