Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix implicit body asserts on compressed response body #568

Merged
merged 1 commit into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion integration/test_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test(format_type, hurl_file):
expected = open(output_file, encoding="utf-8").read().strip()
actual = decode_string(result.stdout)
if actual != expected:
print(">>> error in stdout")
print(f">>> error in stdout for {format_type}")
print(f"actual: <{actual}>\nexpected: <{expected}>")
sys.exit(1)

Expand Down
12 changes: 12 additions & 0 deletions integration/tests_ok/compressed.curl
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
curl 'http://localhost:8000/compressed/none' --compressed
curl 'http://localhost:8000/compressed/none' --compressed
curl 'http://localhost:8000/compressed/none' --compressed
curl 'http://localhost:8000/compressed/none' --compressed
curl 'http://localhost:8000/compressed/gzip' --compressed
curl 'http://localhost:8000/compressed/gzip' --compressed
curl 'http://localhost:8000/compressed/gzip' --compressed
curl 'http://localhost:8000/compressed/gzip' --compressed
curl 'http://localhost:8000/compressed/zlib' --compressed
curl 'http://localhost:8000/compressed/zlib' --compressed
curl 'http://localhost:8000/compressed/zlib' --compressed
curl 'http://localhost:8000/compressed/zlib' --compressed
# curl needs to be built with brotli support
curl 'http://localhost:8000/compressed/brotli' --compressed
curl 'http://localhost:8000/compressed/brotli' --compressed
curl 'http://localhost:8000/compressed/brotli' --compressed
curl 'http://localhost:8000/compressed/brotli' --compressed
curl 'http://localhost:8000/compressed/brotli_identity' --compressed

77 changes: 76 additions & 1 deletion integration/tests_ok/compressed.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<pre><code class="language-hurl"><span class="hurl-entry"><span class="request"><span class="line"></span><span class="comment"># -- COMPRESSED HAS NO EFFECT ON NON-COMPRESSED</span>
<pre><code class="language-hurl"><span class="hurl-entry"><span class="request"><span class="line"></span><span class="comment"># Uncompressed body tests:</span>
<span class="line"></span><span class="comment"># ---------------------------</span>
<span class="line"></span><span class="comment"># --compressed has no effect on non compressed.</span>
<span class="line"></span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/none</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
<span class="line"><span class="string">Content-Length</span><span>:</span> <span class="string">12</span></span>
Expand All @@ -10,6 +13,25 @@
<span class="line"><span class="query-type">md5</span> <span class="predicate-type">==</span> hex,<span class="hex">ed076287532e86365e841e92bfc50d8c</span>;</span>
<span class="raw"><span class="line">```Hello World!```</span></span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span><span class="comment"># Test base64 implicit body:</span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/none</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
<span class="line">base64,<span class="base64">SGVsbG8gV29ybGQh</span>;</span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span><span class="comment"># Test hex implicit body:</span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/none</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
<span class="line">hex,<span class="hex">48656c6c6f20576f726c6421</span>;</span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span><span class="comment"># Test file implicit body:</span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/none</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
<span class="line">file,<span class="filename">hello.txt</span>;</span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span>
<span class="line"></span><span class="comment"># GZip compressed body tests:</span>
<span class="line"></span><span class="comment"># ---------------------------</span>
<span class="line"></span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/gzip</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
<span class="line"><span class="string">Content-Length</span><span>:</span> <span class="string">32</span></span>
Expand All @@ -22,6 +44,25 @@
<span class="line"><span class="query-type">md5</span> <span class="predicate-type">==</span> hex,<span class="hex">ed076287532e86365e841e92bfc50d8c</span>;</span>
<span class="raw"><span class="line">```Hello World!```</span></span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span><span class="comment"># Test base64 implicit body:</span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/gzip</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
<span class="line">base64,<span class="base64">SGVsbG8gV29ybGQh</span>;</span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span><span class="comment"># Test hex implicit body:</span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/gzip</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
<span class="line">hex,<span class="hex">48656c6c6f20576f726c6421</span>;</span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span><span class="comment"># Test file implicit body:</span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/gzip</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
<span class="line">file,<span class="filename">hello.txt</span>;</span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span>
<span class="line"></span><span class="comment"># ZLib compressed body tests:</span>
<span class="line"></span><span class="comment"># ---------------------------</span>
<span class="line"></span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/zlib</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
<span class="line"><span class="string">Content-Length</span><span>:</span> <span class="string">20</span></span>
Expand All @@ -34,6 +75,25 @@
<span class="line"><span class="query-type">md5</span> <span class="predicate-type">==</span> hex,<span class="hex">ed076287532e86365e841e92bfc50d8c</span>;</span>
<span class="raw"><span class="line">```Hello World!```</span></span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span><span class="comment"># Test base64 implicit body:</span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/zlib</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
<span class="line">base64,<span class="base64">SGVsbG8gV29ybGQh</span>;</span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span><span class="comment"># Test hex implicit body:</span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/zlib</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
<span class="line">hex,<span class="hex">48656c6c6f20576f726c6421</span>;</span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span><span class="comment"># Test file implicit body:</span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/zlib</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
<span class="line">file,<span class="filename">hello.txt</span>;</span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span>
<span class="line"></span><span class="comment"># Brotli compressed body tests:</span>
<span class="line"></span><span class="comment"># ---------------------------</span>
<span class="line"></span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/brotli</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
<span class="line"><span class="string">Content-Length</span><span>:</span> <span class="string">17</span></span>
Expand All @@ -46,6 +106,21 @@
<span class="line"><span class="query-type">md5</span> <span class="predicate-type">==</span> hex,<span class="hex">ed076287532e86365e841e92bfc50d8c</span>;</span>
<span class="raw"><span class="line">```Hello World!```</span></span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span><span class="comment"># Test base64 implicit body:</span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/brotli</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
<span class="line">base64,<span class="base64">SGVsbG8gV29ybGQh</span>;</span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span><span class="comment"># Test hex implicit body:</span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/brotli</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
<span class="line">hex,<span class="hex">48656c6c6f20576f726c6421</span>;</span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"></span><span class="comment"># Test file implicit body:</span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/brotli</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
<span class="line">file,<span class="filename">hello.txt</span>;</span>
</span></span><span class="hurl-entry"><span class="request"><span class="line"></span>
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/brotli_identity</span></span>
</span><span class="response"><span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
<span class="line"><span class="string">Content-Length</span><span>:</span> <span class="string">17</span></span>
Expand Down
77 changes: 76 additions & 1 deletion integration/tests_ok/compressed.hurl
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# -- COMPRESSED HAS NO EFFECT ON NON-COMPRESSED
# Uncompressed body tests:
# ---------------------------
# --compressed has no effect on non compressed.

GET http://localhost:8000/compressed/none
HTTP/1.0 200
Content-Length: 12
Expand All @@ -10,6 +13,25 @@ sha256 == hex,7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069;
md5 == hex,ed076287532e86365e841e92bfc50d8c;
```Hello World!```

# Test base64 implicit body:
GET http://localhost:8000/compressed/none
HTTP/1.0 200
base64,SGVsbG8gV29ybGQh;

# Test hex implicit body:
GET http://localhost:8000/compressed/none
HTTP/1.0 200
hex,48656c6c6f20576f726c6421;

# Test file implicit body:
GET http://localhost:8000/compressed/none
HTTP/1.0 200
file,hello.txt;


# GZip compressed body tests:
# ---------------------------

GET http://localhost:8000/compressed/gzip
HTTP/1.0 200
Content-Length: 32
Expand All @@ -22,6 +44,25 @@ sha256 == hex,7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069;
md5 == hex,ed076287532e86365e841e92bfc50d8c;
```Hello World!```

# Test base64 implicit body:
GET http://localhost:8000/compressed/gzip
HTTP/1.0 200
base64,SGVsbG8gV29ybGQh;

# Test hex implicit body:
GET http://localhost:8000/compressed/gzip
HTTP/1.0 200
hex,48656c6c6f20576f726c6421;

# Test file implicit body:
GET http://localhost:8000/compressed/gzip
HTTP/1.0 200
file,hello.txt;


# ZLib compressed body tests:
# ---------------------------

GET http://localhost:8000/compressed/zlib
HTTP/1.0 200
Content-Length: 20
Expand All @@ -34,6 +75,25 @@ sha256 == hex,7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069;
md5 == hex,ed076287532e86365e841e92bfc50d8c;
```Hello World!```

# Test base64 implicit body:
GET http://localhost:8000/compressed/zlib
HTTP/1.0 200
base64,SGVsbG8gV29ybGQh;

# Test hex implicit body:
GET http://localhost:8000/compressed/zlib
HTTP/1.0 200
hex,48656c6c6f20576f726c6421;

# Test file implicit body:
GET http://localhost:8000/compressed/zlib
HTTP/1.0 200
file,hello.txt;


# Brotli compressed body tests:
# ---------------------------

GET http://localhost:8000/compressed/brotli
HTTP/1.0 200
Content-Length: 17
Expand All @@ -46,6 +106,21 @@ sha256 == hex,7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069;
md5 == hex,ed076287532e86365e841e92bfc50d8c;
```Hello World!```

# Test base64 implicit body:
GET http://localhost:8000/compressed/brotli
HTTP/1.0 200
base64,SGVsbG8gV29ybGQh;

# Test hex implicit body:
GET http://localhost:8000/compressed/brotli
HTTP/1.0 200
hex,48656c6c6f20576f726c6421;

# Test file implicit body:
GET http://localhost:8000/compressed/brotli
HTTP/1.0 200
file,hello.txt;

GET http://localhost:8000/compressed/brotli_identity
HTTP/1.0 200
Content-Length: 17
Expand Down
Loading