Package org.archive.wayback.util.http

Examples of org.archive.wayback.util.http.HttpRequestMessage


        port = 80;
      }
      byte GET[] = "GET".getBytes();
      byte HTTP11[] = "HTTP/1.1".getBytes();
      InetAddress addr = InetAddress.getByName(hostname);
      HttpRequestMessage requestMessage = new HttpRequestMessage(
          GET,url.getFile().getBytes(),HTTP11);
      ANVLRecord headers = new ANVLRecord();
      headers.addLabelValue("Host", hostname);
     
     
      if(offset != 0) {
        headers.addLabelValue(RANGE_HTTP_HEADER,
            HEADER_BYTES_PREFIX + String.valueOf(offset) +
              HEADER_BYTES_SUFFIX);
      }
      InetSocketAddress sockAddr = new InetSocketAddress(addr,port);
      Socket socket = new Socket();
      socket.setSoTimeout(socketTimeoutMs);
      socket.setReceiveBufferSize(BUF_SIZE);

      socket.connect(sockAddr, connectTimeoutMs);
      OutputStream socketOut = socket.getOutputStream();
      InputStream socketIn = socket.getInputStream();
      socketOut.write(requestMessage.getBytes(true));
      socketOut.write(headers.getUTF8Bytes());
      socketOut.flush();
      HttpResponse response = HttpResponse.load(socketIn);
      String contentType = response.getHeaders().asMap().get("Content-Type");
      if(contentType == null) {
View Full Code Here

TOP

Related Classes of org.archive.wayback.util.http.HttpRequestMessage

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.