Sha256: a6cd7d4b193876b420cebd530df844082aed27b9d9bf44931e61dd65dec8f949

Contents?: true

Size: 1.55 KB

Versions: 8

Compression:

Stored size: 1.55 KB

Contents

package http_parser.lolevel;

import java.nio.*;
import java.util.*;

import http_parser.ParserType;

import static http_parser.lolevel.Util.*;

public class WrongContentLength {
  static final String contentLength = "GET / HTTP/1.0\r\n" +
                                      "Content-Length: 5\r\n" +
                                      "\r\n" +
                                      "hello" +
                                      "hello_again";
  static void test () {
    HTTPParser parser = new HTTPParser(ParserType.HTTP_REQUEST);
    ByteBuffer buf    = buffer(contentLength);
    
    Settings settings = new Settings();

    int read = parser.execute(settings, buf);
    check (settings.msg_cmplt_called);
    check ("invalid method".equals(settings.err));
  
  }
  public static void main(String [] args) {
    test();
  }

  static class Settings extends ParserSettings {
    public int bodyCount;
    public boolean msg_cmplt_called;
    public String err;
    Settings () {
      this.on_message_complete = new HTTPCallback () {
        public int cb (HTTPParser p) {
          check (5 == bodyCount);
          msg_cmplt_called = true;
          return 0;
        }
      };
      this.on_body = new HTTPDataCallback() {
        public int cb (HTTPParser p, ByteBuffer b, int pos, int len) {
          bodyCount += len;
          p(str(b, pos, len));
          return 0;
        }
      }; 
      this.on_error = new HTTPErrorCallback() {
        public void cb (HTTPParser p, String mes, ByteBuffer b, int i) {
          err = mes;
        }
      };
    }
  }

}

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
http_parser.rb-0.5.3 ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/WrongContentLength.java
http_parser.rb-0.5.3-x86-mswin32-60 ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/WrongContentLength.java
http_parser.rb-0.5.3-x86-mingw32 ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/WrongContentLength.java
http_parser.rb-0.5.3-java ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/WrongContentLength.java
http_parser.rb-0.5.2-x86-mswin32-60 ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/WrongContentLength.java
http_parser.rb-0.5.2-x86-mingw32 ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/WrongContentLength.java
http_parser.rb-0.5.2 ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/WrongContentLength.java
http_parser.rb-0.5.2-java ext/ruby_http_parser/vendor/http-parser-java/src/test/http_parser/lolevel/WrongContentLength.java