Package sunlabs.brazil.util.http

Examples of sunlabs.brazil.util.http.MimeHeaders


   * one line, they are separated by ';' characters.
   */

  String value = null;
  String[] subs = new String[3];
  MimeHeaders headers = request.headers;
  for (int i = headers.size(); --i >= 0; ) {
      if (headers.getKey(i).equalsIgnoreCase("Cookie") == false) {
    continue;
      }
      if (cookie.match(headers.get(i), subs)) {
    value = subs[2];
    if (value.length() == 0) {
        value = null;
    }
    break;
View Full Code Here


      hr.request.log(Server.LOG_DIAGNOSTIC, hr.prefix,
    "Posting: " + post);
      debug(hr, post);
  }

  MimeHeaders clientHeaders = new MimeHeaders();
  hr.request.headers.copyTo(clientHeaders);
  HttpRequest.removePointToPointHeaders(clientHeaders, false);
  clientHeaders.remove("host");

  /*
   * Fix broken query strings - this is dubious
   */

  if (encodeQuery) {
      int index = href.indexOf("?");
      if (index > 0) {
    href = href.substring(0,index+1) +
      href.substring(index+1).replace(' ', '+');
      }
  }

  /*
   * build a query string based on properties
   */

  if (queryList != null) {
      StringTokenizer st = new StringTokenizer(queryList);
            StringBuffer sb = new StringBuffer(href);
      String delim = href.indexOf("?") > 0 ? "&" : "?";
      while (st.hasMoreTokens()) {
          String key = st.nextToken();
          String value = hr.request.props.getProperty(key);
    sb.append(delim).append(key).append("=");
    if (value != null) {
        sb.append(HttpUtil.urlEncode(value));
    }
    delim="&";
      }
      href = sb.toString();
      debug(hr, "Using href: " + href);
  }

  HttpRequest target = new HttpRequest(href);
  clientHeaders.copyTo(target.requestHeaders);
  if (addheaders != null) {
      target.addHeaders(addheaders, hr.request.props);
  }
  target.requestHeaders.putIfNotPresent("Host",
      HttpUtil.extractUrlHost(href));
View Full Code Here

    String
    fetchCookie(Request request) {
  String id = null;
  String[] subs = new String[3];
  MimeHeaders headers = request.headers;
  for (int i = headers.size(); --i >= 0; ) {
      if (headers.getKey(i).equalsIgnoreCase("Cookie") == false) {
    continue;
      }
      request.log(Server.LOG_DIAGNOSTIC, propsPrefix,
        "Examining cookie header: " + headers.get(i));
      if (cookieExp.match(headers.get(i), subs)) {
    id = subs[2];
    if (id.length() == 0) {
        id = null;
    }
    request.log(Server.LOG_DIAGNOSTIC, propsPrefix,
View Full Code Here

  }
  if ((client.query != null) && (client.query.length() > 0)) {
      url += "?" + client.query;
  }

  MimeHeaders clientHeaders = client.headers;

  /*
   * "Proxy-Connection" may be used (instead of just "Connection")
   * to keep alive a connection between a client and this proxy.
   */
  String pc = clientHeaders.get("Proxy-Connection");
  if (pc != null) {
      client.connectionHeader = "Proxy-Connection";
      client.keepAlive = pc.equalsIgnoreCase("Keep-Alive");
  }

  HttpRequest.removePointToPointHeaders(clientHeaders, false);

        HttpRequest target = new HttpRequest(url);
  try {
      MimeHeaders targetHeaders = target.requestHeaders;

      target.setMethod(client.method);
      clientHeaders.copyTo(targetHeaders);
/*      targetHeaders.add("Via", client.protocol + via);*/
     
      /*
       * We might need to authenticate to a target proxy.
       */

      if ((proxyHost != null)
        && proxyTester.useProxy(target.host, target.port)) {
    target.setProxy(proxyHost, proxyPort);
    if (auth != null) {
        targetHeaders.add("Proxy-Authorization", auth);
    }
      }

      if (client.postData != null) {
    OutputStream out = target.getOutputStream();
    out.write(client.postData);
    out.close();
      }

      target.connect();

      targetHeaders = target.responseHeaders;
      HttpRequest.removePointToPointHeaders(targetHeaders, true);

      clientHeaders = client.responseHeaders;
      targetHeaders.copyTo(clientHeaders);
      try {
    clientHeaders.add("Via",
      target.status.substring(0, 8) + via);
      } catch (StringIndexOutOfBoundsException e) {
    clientHeaders.add("Via", via);
View Full Code Here

  if ((admin != null) && request.url.startsWith(admin)) {
      return getInfo(request);
  }

  if (request.url.startsWith("http://")) {
      MimeHeaders headers = request.headers;
      for (int i = headers.size(); --i >= 0; ) {
    if ("Cookie".equalsIgnoreCase(headers.getKey(i))) {
        headers.remove(i);
    }
      }

      insertCookies(request);
  }
View Full Code Here

  }
 
  requestsLeft = server.maxRequests;
  keepAlive = true;

  headers = new MimeHeaders();
  responseHeaders = new MimeHeaders();
  serverProtocol = null;
    }
View Full Code Here

TOP

Related Classes of sunlabs.brazil.util.http.MimeHeaders

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.