Package org.jboss.netty.handler.codec.http

Examples of org.jboss.netty.handler.codec.http.HttpRequest


  {
    // HACK
    // Workaround a netty bug in which writeCompleted() and channelClosed() get called
    // at the same time in different threads. We pull a local copy of _request and deal
    // with it, so that even if _request is set to null during processing, we are fine.
    HttpRequest req = _request;

    String method = (null != req) ? req.getMethod().getName() : "ERR";
    String uri = (null != req) ? req.getUri() : "ERR";
    int respCode = (null != _response) ? _response.getStatus().getCode() : 0;

    _respFinishNano = System.nanoTime();

    StringBuilder logLineBuilder = new StringBuilder(10000);
View Full Code Here


  //auxiliary method to print messages
  private void printMessage(String prefix, MessageEvent e) {
    Object msgO = e.getMessage();
    String resp;
    if(msgO instanceof HttpRequest) {
      HttpRequest msgReq = (HttpRequest)msgO;
      //Matcher result = pattern.matcher(msgReq.getUri());
      resp = msgReq.getUri();
    } else if(msgO instanceof HttpResponse){
      HttpResponse msgReq = (HttpResponse)msgO;
      resp = msgReq.toString();
    } else  if(msgO instanceof HttpChunk){
      HttpChunk msgReq = (HttpChunk)msgO;
      resp = msgReq.toString();
    } else {
      ChannelBuffer msg = (ChannelBuffer)msgO;
      byte[] bytes = new byte[msg.capacity()];
      msg.readBytes(bytes);
      msg.setIndex(0, bytes.length);
View Full Code Here

    Pattern pattern = Pattern.compile(regex);

    Assert.assertTrue(objCapture.waitForMessage(timeout, 0));
    Object msgObj = objCapture.getMessages().get(0);
    Assert.assertTrue(msgObj instanceof HttpRequest);
    HttpRequest msgReq = (HttpRequest)msgObj;
    Matcher result = pattern.matcher(msgReq.getUri());
    Assert.assertTrue(result.matches());

    return result;
  }
View Full Code Here

                     throw new RuntimeException("Handshake failed after timeout");
                  }
               }
            }

            HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, url);
            if (cookie != null)
            {
               httpRequest.addHeader(HttpHeaders.Names.COOKIE, cookie);
            }
            ChannelBuffer buf = (ChannelBuffer)e.getMessage();
            httpRequest.setContent(buf);
            httpRequest.addHeader(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(buf.writerIndex()));
            Channels.write(ctx, e.getFuture(), httpRequest, e.getRemoteAddress());
            lastSendTime = System.currentTimeMillis();
         }
         else
         {
View Full Code Here

               return;
            }

            if (!waitingGet && System.currentTimeMillis() > lastSendTime + httpMaxClientIdleTime)
            {
               HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, url);
               waitingGet = true;
               channel.write(httpRequest);
            }
         }
View Full Code Here

                     throw new RuntimeException("Handshake failed after timeout");
                  }
               }
            }

            HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, url);
            httpRequest.addHeader(HttpHeaders.Names.HOST, NettyConnector.this.host);
            if (cookie != null)
            {
               httpRequest.addHeader(HttpHeaders.Names.COOKIE, cookie);
            }
            ChannelBuffer buf = (ChannelBuffer)e.getMessage();
            httpRequest.setContent(buf);
            httpRequest.addHeader(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(buf.writerIndex()));
            Channels.write(ctx, e.getFuture(), httpRequest, e.getRemoteAddress());
            lastSendTime = System.currentTimeMillis();
         }
         else
         {
View Full Code Here

               return;
            }

            if (!waitingGet && System.currentTimeMillis() > lastSendTime + httpMaxClientIdleTime)
            {
               HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, url);
               httpRequest.addHeader(HttpHeaders.Names.HOST, NettyConnector.this.host);
               waitingGet = true;
               channel.write(httpRequest);
            }
         }
View Full Code Here

                     throw new RuntimeException("Handshake failed after timeout");
                  }
               }
            }

            HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, url);
            if (cookie != null)
            {
               httpRequest.addHeader(HttpHeaders.Names.COOKIE, cookie);
            }
            ChannelBuffer buf = (ChannelBuffer)e.getMessage();
            httpRequest.setContent(buf);
            httpRequest.addHeader(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(buf.writerIndex()));
            Channels.write(ctx, e.getFuture(), httpRequest, e.getRemoteAddress());
            lastSendTime = System.currentTimeMillis();
         }
         else
         {
View Full Code Here

               return;
            }

            if (!waitingGet && System.currentTimeMillis() > lastSendTime + httpMaxClientIdleTime)
            {
               HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.GET, url);
               waitingGet = true;
               channel.write(httpRequest);
            }
         }
View Full Code Here

                     throw new RuntimeException("Handshake failed after timeout");
                  }
               }
            }

            HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, url);
            if (cookie != null)
            {
               httpRequest.addHeader(HttpHeaders.Names.COOKIE, cookie);
            }
            ChannelBuffer buf = (ChannelBuffer)e.getMessage();
            httpRequest.setContent(buf);
            httpRequest.addHeader(HttpHeaders.Names.CONTENT_LENGTH, String.valueOf(buf.writerIndex()));
            Channels.write(ctx, e.getFuture(), httpRequest, e.getRemoteAddress());
            lastSendTime = System.currentTimeMillis();
         }
         else
         {
View Full Code Here

TOP

Related Classes of org.jboss.netty.handler.codec.http.HttpRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.