Sha256: 25b4503fd5971c6863e2c085d8dfdc30307c85a5f5cf1d8fc4fc38417c081e43

Contents?: true

Size: 1.57 KB

Versions: 21

Compression:

Stored size: 1.57 KB

Contents

package http_parser.lolevel;

import java.nio.*;

import static http_parser.lolevel.Util.*;

public class TestNoOverflowLongBody {

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

    parser.execute(Util.SETTINGS_NULL, buf);

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

    buf  = buffer("a");
    buflen  = buf.limit();
    
    for (int i = 0; i!= len; ++i) {
      parser.execute(Util.SETTINGS_NULL, buf);
      check(buflen == buf.position());
      buf.rewind();
    }
    
    buf = getBytes(type, len);
    buflen = buf.limit();

    parser.execute(Util.SETTINGS_NULL, buf);

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

  }

  static ByteBuffer getBytes (http_parser.ParserType type, int length) {
    if (http_parser.ParserType.HTTP_BOTH == type) {
      throw new RuntimeException("only HTTP_REQUEST and HTTP_RESPONSE");
    }
    
    String template = "%s\r\nConnection: Keep-Alive\r\nContent-Length: %d\r\n\r\n";
    String str = null;
    if (http_parser.ParserType.HTTP_REQUEST == type) {
      str = String.format(template, "GET / HTTP/1.1", length); 
    } else {
      str = String.format(template, "HTTP/1.0 200 OK", length);
    }
    return buffer(str);
  }

  public static void test () {
    p(TestNoOverflowLongBody.class);
    test(http_parser.ParserType.HTTP_REQUEST, 1000);
    test(http_parser.ParserType.HTTP_REQUEST, 100000);
    test(http_parser.ParserType.HTTP_RESPONSE, 1000);
    test(http_parser.ParserType.HTTP_RESPONSE, 100000);
  }



}

Version data entries

21 entries across 21 versions & 7 rubygems

Version Path
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
fluent-plugin-google-cloud-logging-on-prem-0.1.0 vendor/ruby/3.1.0/gems/http_parser.rb-0.8.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
http_parser.rb-0.8.0 ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
http_parser.rb-0.7.0 ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
fluent-plugin-detect-memb-exceptions-0.0.2 vendor/bundle/ruby/2.0.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
fluent-plugin-detect-memb-exceptions-0.0.1 vendor/bundle/ruby/2.0.0/gems/http_parser.rb-0.6.0/ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
midori_http_parser-0.6.1.3 ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
midori_http_parser-0.6.1.3-java ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
midori_http_parser-0.6.1.2-java ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
midori_http_parser-0.6.1.2 ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
midori_http_parser-0.6.1.1-java ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
midori_http_parser-0.6.1.1 ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
midori_http_parser-0.6.1 ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
http_parser.rb-0.6.0-java ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
http_parser.rb-0.6.0 ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
http_parser.rb-0.6.0.beta.2-java ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java
http_parser.rb-0.6.0.beta.2 ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/TestNoOverflowLongBody.java