Skip to content

Commit b966cba

Browse files
committed
improve: add http_parser test
1 parent cb66b86 commit b966cba

File tree

64 files changed

+3215
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+3215
-0
lines changed

luaio

649 Bytes
Binary file not shown.

test/http_parser/AMAZON_COM.txt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
HTTP/1.1 301 MovedPermanently
2+
Date: Wed, 15 May 2013 17:06:33 GMT
3+
Server: Server
4+
x-amz-id-1: 0GPHKXSJQ826RK7GZEB2
5+
p3p: policyref="http://www.amazon.com/w3c/p3p.xml",CP="CAO DSP LAW CUR ADM IVAo IVDo CONo OTPo OUR DELi PUBi OTRi BUS PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA HEA PRE LOC GOV OTC "
6+
x-amz-id-2: STN69VZxIFSz9YJLbz1GDbxpbjG6Qjmmq5E3DxRhOUw+Et0p4hr7c/Q8qNcx4oAD
7+
Location: http://www.amazon.com/Dan-Brown/e/B000AP9DSU/ref=s9_pop_gw_al1?_encoding=UTF8&refinementId=618073011&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=center-2&pf_rd_r=0SHYY5BZXN3KR20BNFAY&pf_rd_t=101&pf_rd_p=1263340922&pf_rd_i=507846
8+
Vary: Accept-Encoding,User-Agent
9+
Content-Type: text/html; charset=ISO-8859-1
10+
Transfer-Encoding: chunked
11+
12+
1
13+
14+
15+
0
16+

test/http_parser/APACHEBENCH_GET.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
GET /test HTTP/1.0
2+
Host: 0.0.0.0:5000
3+
User-Agent: ApacheBench/2.3
4+
Accept: */*
5+
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
HTTP/1.0 301 Moved Permanently
2+
Date: Thu, 03 Jun 2010 09:56:32 GMT
3+
Server: Apache/2.2.3 (Red Hat)
4+
Cache-Control: public
5+
Pragma:
6+
Location: http://www.bonjourmadame.fr/
7+
Vary: Accept-Encoding
8+
Content-Length: 0
9+
Content-Type: text/html; charset=UTF-8
10+
Connection: keep-alive
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
POST /chunked_w_bullshit_after_length HTTP/1.1
2+
Transfer-Encoding: chunked
3+
4+
5; ihatew3;whatthefuck=aretheseparametersfor
5+
hello
6+
6; blahblah; blah
7+
world
8+
0
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
POST /chunked_w_trailing_headers HTTP/1.1
2+
Transfer-Encoding: chunked
3+
4+
5
5+
hello
6+
6
7+
world
8+
0
9+
Vary: *
10+
Content-Type: text/plain
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
GET /demo HTTP/1.1
2+
Connection: keep-alive, upgrade
3+
Upgrade: WebSocket
4+
5+
Hot diggity dogg
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONNECT HOME0.NETSCAPE.COM:443 HTTP/1.0
2+
User-agent: Mozilla/1.1N
3+
Proxy-authorization: basic aGVsbG86d29ybGQ=
4+

test/http_parser/CONNECT_REQUEST.txt

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CONNECT 0-home0.netscape.com:443 HTTP/1.0
2+
User-agent: Mozilla/1.1N
3+
Proxy-authorization: basic aGVsbG86d29ybGQ=
4+
5+
some data
6+
and yet even more data
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
CONNECT foo.bar.com:443 HTTP/1.0
2+
User-agent: Mozilla/1.1N
3+
Proxy-authorization: basic aGVsbG86d29ybGQ=
4+
Content-Length: 10
5+
6+
blarfcicle

test/http_parser/CURL_GET.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
GET /test HTTP/1.1
2+
User-Agent: curl/7.18.0 (i486-pc-linux-gnu) libcurl/7.18.0 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.1
3+
Host: 0.0.0.0=5000
4+
Accept: */*
5+

test/http_parser/DUMBFUCK.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GET /dumbfuck HTTP/1.1
2+
aaaaaaaaaaaaa:++++++++++
3+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
POST / HTTP/1.1
2+
Host: www.example.com
3+
Content-Type: application/x-www-form-urlencoded
4+
Content-Length: 4
5+
6+
q=42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
POST / HTTP/1.1
2+
Host: www.example.com
3+
Content-Type: application/x-www-form-urlencoded
4+
Content-Length: 4
5+
Connection: close
6+
7+
q=42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
HTTP/1.1 200
2+

test/http_parser/FIREFOX_GET.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
GET /favicon.ico HTTP/1.1
2+
Host: 0.0.0.0=5000
3+
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9) Gecko/2008061015 Firefox/3.0
4+
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
5+
Accept-Language: en-us,en;q=0.5
6+
Accept-Encoding: gzip,deflate
7+
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
8+
Keep-Alive: 300
9+
Connection: keep-alive
10+

test/http_parser/FRAGMENT_IN_URI.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GET /forums/1/topics/2375?page=1#posts-17408 HTTP/1.1
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
GET /get_funky_content_length_body_hello HTTP/1.0
2+
conTENT-Length: 5
3+
4+
HELLO
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GET /get_no_headers_no_body/world HTTP/1.1
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GET /get_one_headers_no_body/world HTTP/1.1
2+
Accept: */*
3+

test/http_parser/GOOGLE_301.txt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
HTTP/1.1 301 Moved Permanently
2+
Location: http://www.google.com/
3+
Content-Type: text/html; charset=UTF-8
4+
Date: Sun, 26 Apr 2009 11:11:49 GMT
5+
Expires: Tue, 26 May 2009 11:11:49 GMT
6+
X-$PrototypeBI-Version: 1.6.0.3
7+
Cache-Control: public, max-age=2592000
8+
Server: gws
9+
Content-Length: 219
10+
11+
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
12+
<TITLE>301 Moved</TITLE></HEAD><BODY>
13+
<H1>301 Moved</H1>
14+
The document has moved
15+
<A HREF="http://www.google.com/">here</A>.
16+
</BODY></HTML>

test/http_parser/HTTP_VERSION_0_9.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
HTTP/0.9 200 OK
2+

test/http_parser/MSEARCH_REQ.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
M-SEARCH * HTTP/1.1
2+
HOST: 239.255.255.250:1900
3+
MAN: "ssdp:discover"
4+
ST: "ssdp:all"
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
HTTP/1.1 500 Oriëntatieprobleem
2+
Date: Fri, 5 Nov 2010 23:07:12 GMT+2
3+
Content-Length: 0
4+
Connection: close
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
HTTP/1.0 200 OK
2+
Connection: keep-alive
3+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
HTTP/1.0 204 No content
2+
Connection: keep-alive
3+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
HTTP/1.1 200 OK
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
HTTP/1.1 204 No content
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
HTTP/1.1 200 OK
2+
Transfer-Encoding: chunked
3+
4+
0
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
HTTP/1.1 204 No content
2+
Connection: close
3+

test/http_parser/NO_CARRIAGE_RET.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
HTTP/1.1 200 OK
2+
Content-Type: text/html; charset=utf-8
3+
Connection: close
4+
5+
these headers are from http://news.ycombinator.com/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
HTTP/1.1 200 OK
2+
Content-Type: text/plain
3+
4+
hello world
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
HTTP/1.1 200 OK
2+
Date: Tue, 04 Aug 2009 07:59:32 GMT
3+
Server: Apache
4+
X-Powered-By: Servlet/2.5 JSP/2.1
5+
Content-Type: text/xml; charset=utf-8
6+
Connection: close
7+
8+
<?xml version="1.0" encoding="UTF-8"?>
9+
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
10+
<SOAP-ENV:Body>
11+
<SOAP-ENV:Fault>
12+
<faultcode>SOAP-ENV:Client</faultcode>
13+
<faultstring>Client Error</faultstring>
14+
</SOAP-ENV:Fault>
15+
</SOAP-ENV:Body>
16+
</SOAP-ENV:Envelope>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
HTTP/1.1 404 Not Found
2+

test/http_parser/NO_HTTP_VERSION.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GET /
2+

test/http_parser/NO_REASON_PHRASE.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
HTTP/1.1 301
2+

test/http_parser/PATCH_REQ.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
PATCH /file.txt HTTP/1.1
2+
Host: www.example.com
3+
Content-Type: application/example
4+
If-Match: "e0023aa4e"
5+
Content-Length: 10
6+
7+
cccccccccc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
POST /post_chunked_all_your_base HTTP/1.1
2+
Transfer-Encoding: chunked
3+
4+
1e
5+
all your base are belong to us
6+
0
7+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
POST /post_identity_body_world?q=search#hey HTTP/1.1
2+
Accept: */*
3+
Transfer-Encoding: identity
4+
Content-Length: 5
5+
6+
World
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
GET /test HTTP/1.1
3+

test/http_parser/PROXY_CONNECTION.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
HTTP/1.1 200 OK
2+
Content-Type: text/html; charset=UTF-8
3+
Content-Length: 11
4+
Proxy-Connection: close
5+
Date: Thu, 31 Dec 2009 20:55:48 +0000
6+
7+
hello world
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GET http://a%12:b!&*[email protected]:1234/toto HTTP/1.1
2+

test/http_parser/PURGE_REQ.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
PURGE /file.txt HTTP/1.1
2+
Host: www.example.com
3+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GET http://hypnotoad.org?hail=all HTTP/1.1
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GET http://hypnotoad.org:1234?hail=all HTTP/1.1
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GET /test.cgi?foo=bar?baz HTTP/1.1
2+

test/http_parser/REPORT_REQ.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
REPORT /test HTTP/1.1
2+
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
HTTP/1.1 200 OK
2+
Date: Tue, 28 Sep 2010 01:14:13 GMT
3+
Server: Apache
4+
Cache-Control: no-cache, must-revalidate
5+
Expires: Mon, 26 Jul 1997 05:00:00 GMT
6+
.et-Cookie: PlaxoCS=1274804622353690521; path=/; domain=.plaxo.com
7+
Vary: Accept-Encoding
8+
_eep-Alive: timeout=45
9+
_onnection: Keep-Alive
10+
Transfer-Encoding: chunked
11+
Content-Type: text/html
12+
Connection: close
13+
14+
0
15+

test/http_parser/SEARCH_REQ.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SEARCH / HTTP/1.1
2+
Host: www.example.com
3+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GET http://hypnotoad.org:1234 HTTP/1.1
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
HTTP/1.1 200 OK
2+
Content-Type: text/plain
3+
Transfer-Encoding: chunked
4+
5+
25
6+
This is the data in the first chunk
7+
8+
1C
9+
and this is the second one
10+
11+
0
12+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
POST /two_chunks_mult_zero_end HTTP/1.1
2+
Transfer-Encoding: chunked
3+
4+
5
5+
hello
6+
6
7+
world
8+
000
9+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
HTTP/1.1 200 OK
2+
Server: DCLK-AdSvr
3+
Content-Type: text/xml
4+
Content-Length: 0
5+
DCLK_imp: v7;x;114750856;0-0;0;17820020;0/0;21603567/21621457/1;;~okv=;dcmt=text/xml;;~cs=o
6+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
POST /demo HTTP/1.1
2+
Host: example.com
3+
Connection: Upgrade
4+
Upgrade: HTTP/2.0
5+
Content-Length: 15
6+
7+
sweet post bodyHot diggity dogg

test/http_parser/UPGRADE_REQUEST.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
GET /demo HTTP/1.1
2+
Host: example.com
3+
Connection: Upgrade
4+
Sec-WebSocket-Key2: 12998 5 Y3 1 .P00
5+
Sec-WebSocket-Protocol: sample
6+
Upgrade: WebSocket
7+
Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5
8+
Origin: http://example.com
9+
10+
Hot diggity dogg

test/http_parser/WITH_QUOTES.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GET /with_"stupid"_quotes?foo="bar" HTTP/1.1
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
HTTP/1.1 200
2+

test/read.lua

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
local fs = require('fs')
2+
local ERRNO = require('errno')
3+
4+
local read_stream, err = fs.createReadStream('./http_parser/CURL_GET.txt')
5+
6+
print(ERRNO.parse(err))
7+
8+
local str, err = read_stream:read(20)
9+
10+
print(ERRNO.parse(err))
11+
print(str)
12+
13+
str, err = read_stream:read(99)
14+
15+
print(ERRNO.parse(err))
16+
print(str)
17+
18+
str, err = read_stream:read(9)
19+
20+
print(ERRNO.parse(err))
21+
print(str)

0 commit comments

Comments
 (0)