Sha256: ebce823dcd398b1d0620d16a40dc9c672d0ce5b22a23006dcb0434388531ea04

Contents?: true

Size: 1.13 KB

Versions: 21

Compression:

Stored size: 1.13 KB

Contents

package http_parser.lolevel;

import java.nio.*;

import static http_parser.lolevel.Util.*;

public class TestHeaderOverflowError {

  public static void test (http_parser.ParserType type) {
    HTTPParser parser = new HTTPParser(type);
    ByteBuffer buf    = getBytes(type);
    
    int numbytes = buf.limit();

    parser.execute(Util.SETTINGS_NULL, buf);

    check(numbytes == buf.position());

    buf      = buffer("header-key: header-value\r\n");
    numbytes = buf.limit();
    for (int i = 0; i!= 1000; ++i) {
      parser.execute(Util.SETTINGS_NULL, buf);
      check(numbytes == buf.position());

      buf.rewind();

    }
  }

  static ByteBuffer getBytes (http_parser.ParserType type) {
    if (http_parser.ParserType.HTTP_BOTH == type) {
      throw new RuntimeException("only HTTP_REQUEST and HTTP_RESPONSE");
    }

    if (http_parser.ParserType.HTTP_REQUEST == type) {
      return buffer("GET / HTTP/1.1\r\n"); 
    }
    return buffer("HTTP/1.0 200 OK\r\n");
  }

  public static void test () {
    p(TestHeaderOverflowError.class);
    test(http_parser.ParserType.HTTP_REQUEST);
    test(http_parser.ParserType.HTTP_RESPONSE);
  }


}

Version data entries

21 entries across 21 versions & 7 rubygems

Version Path
http_parser.rb-0.6.0.beta.1 ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestHeaderOverflowError.java