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

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


  }

  public void start(Buffer buf) {
    isReady = false;
    IniProperties cfg = SnovaConfiguration.getInstance().getIniProperties();
    HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1,
        HttpMethod.POST, serv.server.url.toString() + "push");

    String enc = cfg.getProperty("C4", "Encrypter", "RC4");
    if (enc.equalsIgnoreCase("RC4")) {
      String key = cfg.getProperty("Misc", "RC4Key");
      RC4.setDefaultKey(key);
      byte[] tmp = RC4.encrypt(key.getBytes());
      request.setHeader("RC4Key", Base64.encodeToString(tmp, false));
    }
    request.setHeader(HttpHeaders.Names.HOST, serv.server.url.getHost());
    request.setHeader(HttpHeaders.Names.CONNECTION, "keep-alive");
    request.setHeader("UserToken", NetworkHelper.getMacAddress());
    request.setHeader("C4MiscInfo", String.format("%d_%d", index, 25));
    request.setHeader(
        HttpHeaders.Names.USER_AGENT,
        cfg.getProperty("C4", "UserAgent",
            "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/19.0.1"));
    request.setHeader(HttpHeaders.Names.CONTENT_TYPE,
        "application/octet-stream");
    request.setHeader(HttpHeaders.Names.CONTENT_LENGTH, buf.readableBytes());
    request.setContent(ChannelBuffers.wrappedBuffer(buf.getRawBuffer(),
        buf.getReadIndex(), buf.readableBytes()));
    HttpClient client = HttpTunnelService.httpClient;
    try {
      client.execute(request, new HttpClientFutureCallback(buf));
    } catch (HttpClientException e) {
View Full Code Here


  }
 
  public void start()
  {
    IniProperties cfg = SnovaConfiguration.getInstance().getIniProperties();
    HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1,
            HttpMethod.POST, serv.server.url.toString() + "pull");
    request.setHeader(HttpHeaders.Names.HOST, serv.server.url.getHost());
   
    request.setHeader(HttpHeaders.Names.CONNECTION, "keep-alive");
    request.setHeader("UserToken", NetworkHelper.getMacAddress());
    request.setHeader(
            "C4MiscInfo",
            String.format("%d_%d", index,
                    cfg.getIntProperty("C4", "ReadTimeout", 55)));
    request.setHeader(
            HttpHeaders.Names.USER_AGENT,
            cfg.getProperty("C4", "UserAgent",
                    "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1"));
    request.setHeader(HttpHeaders.Names.CONTENT_TYPE,
            "application/octet-stream");
    request.setHeader(HttpHeaders.Names.CONTENT_LENGTH, "0");
    HttpClient client = HttpTunnelService.httpClient;
    try
    {
      client.execute(request, this);
    }
View Full Code Here

  }
 
  public HttpClientHandler doGet(String url, FutureCallback cb)
          throws HttpClientException
  {
    HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1,
            HttpMethod.GET, url);
    URL u;
    try
    {
      u = new URL(url);
    }
    catch (MalformedURLException e)
    {
      throw new HttpClientException(e);
    }
    request.setHeader("Host", u.getHost());
    return execute(request, cb);
  }
View Full Code Here

    String pa = adjustProxyRequest(proxy, req);
    if (null != proxy && req.getUri().startsWith("https://")
            && !req.getMethod().equals(HttpMethod.CONNECT) && !reuse)
    {
      String addr = HttpHeaders.getHost(req);
      final HttpRequest connReq = new DefaultHttpRequest(
              HttpVersion.HTTP_1_1, HttpMethod.CONNECT, addr);
      connReq.setHeader(HttpHeaders.Names.HOST, addr);
      if (null != pa)
      {
        connReq.setHeader(HttpHeaders.Names.PROXY_AUTHORIZATION, pa);
      }
      final HttpClientHandler tmp = handler;
      handler.setCallback(new FutureCallback.FutureCallbackAdapter()
      {
        public void onResponse(HttpResponse res)
View Full Code Here

        auth = GAE.servers.select();
      }
      int sid = null == local ? 0 : local.getId();
      IniProperties cfg = SnovaConfiguration.getInstance()
              .getIniProperties();
      HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1,
              HttpMethod.POST, "/invoke");
      request.setHeader(HttpHeaders.Names.HOST, auth.appid
              + ".appspot.com");
      request.setHeader(HttpHeaders.Names.CONNECTION, "keep-alive");
      request.setHeader(
              HttpHeaders.Names.USER_AGENT,
              cfg.getProperty("GAE", "UserAgent",
                      "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0.1"));
      request.setHeader(HttpHeaders.Names.CONTENT_TYPE,
              "application/octet-stream");

      EventHeaderTags tags = new EventHeaderTags();
      tags.token = auth.token;
      ev.setHash(sid);
      ev = wrapEvent(ev);
      Buffer buf = EventHelper.encodeEvent(tags, ev);
      request.setHeader(HttpHeaders.Names.CONTENT_LENGTH,
              "" + buf.readableBytes());
      request.setContent(ChannelBuffers.wrappedBuffer(buf.getRawBuffer(),
              buf.getReadIndex(), buf.readableBytes()));
      HttpClientHandler h = client.execute(request, cb);
      workingHttpClientHandlers.add(h);
      cb.httpHandler = h;
    }
View Full Code Here

        super(maxInitialLineLength, maxHeaderSize, maxChunkSize);
    }

    @Override
    protected HttpMessage createMessage(String[] initialLine) throws Exception{
        return new DefaultHttpRequest(
                HttpVersion.valueOf(initialLine[2]), HttpMethod.valueOf(initialLine[0]), initialLine[1]);
    }
View Full Code Here

    }

    @Override
    protected ChannelFuture writeRequest(ChannelBuffer request)
    {
        HttpRequest httpRequest = new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST,
                                                         endpointUri);

        httpRequest.setHeader(HttpHeaders.HOST, hostName);
        httpRequest.setHeader(HttpHeaders.CONTENT_LENGTH, request.readableBytes());
        httpRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/x-thrift");
        httpRequest.setHeader(HttpHeaders.USER_AGENT, "Java/Swift-HttpThriftClientChannel");

        if (headerDictionary != null) {
            for (Map.Entry<String, String> entry : headerDictionary.entrySet()) {
                httpRequest.setHeader(entry.getKey(), entry.getValue());
            }
        }

        httpRequest.setContent(request);

        return underlyingNettyChannel.write(httpRequest);
    }
View Full Code Here

    return bootstrap.connect(new InetSocketAddress(host, port));
  }

  protected HttpRequest prepareRequest(URI uri, String h) {
    // Send the HTTP request.
    HttpRequest request = new DefaultHttpRequest(HttpVersion.HTTP_1_1,
      HttpMethod.GET, uri.toASCIIString());
    headers.setHeader(request, HttpHeaders.Names.HOST, h);
    if (getHttpUser() != null && !getHttpUser().isEmpty()) {
      String basicAuthHeader;
      try {
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

TOP

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

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.