diff options
author | Erik Dubbelboer <erik@dubbelboer.com> | 2024-02-11 14:55:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-11 07:55:31 +0100 |
commit | 332726634240b82456ce8563cd7aa4027612ce36 (patch) | |
tree | 64a7b1862d9d6089e7521a7a2c59f8ea19436fe0 /header_test.go | |
parent | Bump dependencies (#1718) (diff) | |
download | fasthttp-332726634240b82456ce8563cd7aa4027612ce36.tar.gz fasthttp-332726634240b82456ce8563cd7aa4027612ce36.tar.bz2 fasthttp-332726634240b82456ce8563cd7aa4027612ce36.zip |
Follow RFCs 7230 and 9112 for HTTP versions (#1710)
Require that HTTP versions match the following pattern: HTTP/[0-9]\.[0-9]
Diffstat (limited to 'header_test.go')
-rw-r--r-- | header_test.go | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/header_test.go b/header_test.go index 163fdd7..c0f98dc 100644 --- a/header_test.go +++ b/header_test.go @@ -1341,11 +1341,6 @@ func TestRequestHeaderHTTPVer(t *testing.T) { // non-http/1.1 testRequestHeaderHTTPVer(t, "GET / HTTP/1.0\r\nHost: aa.com\r\n\r\n", true) testRequestHeaderHTTPVer(t, "GET / HTTP/0.9\r\nHost: aa.com\r\n\r\n", true) - testRequestHeaderHTTPVer(t, "GET / foobar\r\nHost: aa.com\r\n\r\n", true) - - // empty http version - testRequestHeaderHTTPVer(t, "GET /\r\nHost: aaa.com\r\n\r\n", true) - testRequestHeaderHTTPVer(t, "GET / \r\nHost: aaa.com\r\n\r\n", true) // http/1.1 testRequestHeaderHTTPVer(t, "GET / HTTP/1.1\r\nHost: a.com\r\n\r\n", false) @@ -1365,6 +1360,8 @@ func testResponseHeaderHTTPVer(t *testing.T, s string, connectionClose bool) { } func testRequestHeaderHTTPVer(t *testing.T, s string, connectionClose bool) { + t.Helper() + var h RequestHeader r := bytes.NewBufferString(s) @@ -2641,10 +2638,6 @@ func TestRequestHeaderReadSuccess(t *testing.T) { testRequestHeaderReadSuccess(t, h, "GET http://gooGle.com/foO/%20bar?xxx#aaa HTTP/1.1\r\nHost: aa.cOM\r\n\r\ntrail", -2, "http://gooGle.com/foO/%20bar?xxx#aaa", "aa.cOM", "", "", nil) - // no protocol in the first line - testRequestHeaderReadSuccess(t, h, "GET /foo/bar\r\nHost: google.com\r\n\r\nisdD", - -2, "/foo/bar", "google.com", "", "", nil) - // blank lines before the first line testRequestHeaderReadSuccess(t, h, "\r\n\n\r\nGET /aaa HTTP/1.1\r\nHost: aaa.com\r\n\r\nsss", -2, "/aaa", "aaa.com", "", "", nil) @@ -2713,6 +2706,9 @@ func TestResponseHeaderReadError(t *testing.T) { // forbidden trailer testResponseHeaderReadError(t, h, "HTTP/1.1 200 OK\r\nContent-Length: -1\r\nTrailer: Foo, Content-Length\r\n\r\n") + + // no protocol in the first line + testResponseHeaderReadError(t, h, "GET /foo/bar\r\nHost: google.com\r\n\r\nisdD") } func TestResponseHeaderReadErrorSecureLog(t *testing.T) { |