Package com.google.opengse.iobuffer

Examples of com.google.opengse.iobuffer.IOBuffer


        // CRLF.
        if (buf.availableBytes() >= chunkSize + 2) {
          // As long as this isn't the last chunk (0 length), transfer bytes.
          if (chunkSize > 0) {
            if (post_body_ == null) {
              post_body_ = new IOBuffer();
            }
            post_body_.transfer(buf, chunkSize);
          }
          // Pull off trailing CRLF.
          if (!buf.readLine(line_buf, READLINE_LIMIT)) {
View Full Code Here


    post_body_.flush();
    InputStream inflator_input_stream =
        new GZIPInputStream(new IOBufferInputStream(post_body_), 1024);

    // decompress by writing to a new IO buffer, update body
    IOBuffer inflatedBodyBuffer = new IOBuffer();
    final byte[] byteBuffer = new byte[1024];
    int numBytes;
    while (-1 != (numBytes = inflator_input_stream.read(byteBuffer))) {
      inflatedBodyBuffer.writeBytes(byteBuffer, 0, numBytes);
    }
    inflatedBodyBuffer.flush();

    int inflated_body_length = inflatedBodyBuffer.totalBytes();
    _setPostBody(inflatedBodyBuffer, inflated_body_length);

    // Remove content encoding, set new length, so request forwarding will work
    requestContext.getHeaders().removeHeader("Content-Encoding");
    requestContext.getHeaders().setIntHeader("Content-Length",
View Full Code Here

  protected ParamMap parseParameters(String encoding) {
    ParamMap map = new ParamMap();
    FormUrlDecoder.parse(getQueryString(), map, encoding);

    if (post_body_ != null) {
      IOBuffer params = getPostBody();
      if ("application/x-www-form-urlencoded".equals(getContentType())) {
        // the character encoding on the post body is guaranteed to be US-ASCII
        params.setCharacterEncoding("US-ASCII");

        StringBuilder sb = new StringBuilder();
        char[] char_buf = new char[1024];
        int res;

        while ((res = params.read(char_buf)) > 0) {
          sb.append(char_buf, 0, res);
        }

        FormUrlDecoder.parse(sb.toString(), map, encoding);
      }
View Full Code Here

  public BufferedReader getReader() {
    if (input_stream_ != null) {
      throw new IllegalStateException("getInputStream() called previously");
    }
    if (input_reader_ == null) {
      IOBuffer body = getPostBody();
      body.setCharacterEncoding(getInternalCharacterEncoding());
      input_reader_ = new BufferedReader(new IOBufferReader(body));
    }
    return input_reader_;
  }
View Full Code Here

TOP

Related Classes of com.google.opengse.iobuffer.IOBuffer

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.