mirror of
https://github.com/Orange-OpenSource/hurl.git
synced 2024-12-23 11:02:43 +03:00
Add --compressed entry option.
This commit is contained in:
parent
cd64b3310a
commit
96ef0c7228
21
integration/tests_ok/option_compressed.curl
Normal file
21
integration/tests_ok/option_compressed.curl
Normal file
@ -0,0 +1,21 @@
|
||||
curl 'http://localhost:8000/compressed/none' --compressed
|
||||
curl 'http://localhost:8000/compressed/none'
|
||||
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_large' --compressed
|
||||
curl 'http://localhost:8000/compressed/brotli_identity' --compressed
|
||||
|
213
integration/tests_ok/option_compressed.html
Normal file
213
integration/tests_ok/option_compressed.html
Normal file
@ -0,0 +1,213 @@
|
||||
<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 class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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>
|
||||
<span class="line"><span class="string">Content-Type</span><span>:</span> <span class="string">text/html; charset=utf-8</span></span>
|
||||
<span class="line section-header">[Asserts]</span>
|
||||
<span class="line"><span class="query-type">body</span> <span class="predicate-type">startsWith</span> <span class="string">"Hello"</span></span>
|
||||
<span class="line"><span class="query-type">bytes</span> <span class="predicate-type">startsWith</span> hex,<span class="hex">48656c6c6f</span>;</span>
|
||||
<span class="line"><span class="query-type">sha256</span> <span class="predicate-type">==</span> hex,<span class="hex">7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069</span>;</span>
|
||||
<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 class="method">GET</span> <span class="url">http://localhost:8000/compressed/none</span></span>
|
||||
<span class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">false</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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>
|
||||
<span class="line"><span class="string">Content-Type</span><span>:</span> <span class="string">text/html; charset=utf-8</span></span>
|
||||
<span class="line section-header">[Asserts]</span>
|
||||
<span class="line"><span class="query-type">body</span> <span class="predicate-type">startsWith</span> <span class="string">"Hello"</span></span>
|
||||
<span class="line"><span class="query-type">bytes</span> <span class="predicate-type">startsWith</span> hex,<span class="hex">48656c6c6f</span>;</span>
|
||||
<span class="line"><span class="query-type">sha256</span> <span class="predicate-type">==</span> hex,<span class="hex">7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069</span>;</span>
|
||||
<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="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 class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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 class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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 class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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 class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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>
|
||||
<span class="line"><span class="string">Content-Encoding</span><span>:</span> <span class="string">gzip</span></span>
|
||||
<span class="line"><span class="string">Content-Type</span><span>:</span> <span class="string">text/html; charset=utf-8</span></span>
|
||||
<span class="line section-header">[Asserts]</span>
|
||||
<span class="line"><span class="query-type">body</span> <span class="predicate-type">startsWith</span> <span class="string">"Hello"</span></span>
|
||||
<span class="line"><span class="query-type">bytes</span> <span class="predicate-type">startsWith</span> hex,<span class="hex">48656c6c6f</span>;</span>
|
||||
<span class="line"><span class="query-type">sha256</span> <span class="predicate-type">==</span> hex,<span class="hex">7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069</span>;</span>
|
||||
<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 class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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 class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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 class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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 class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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>
|
||||
<span class="line"><span class="string">Content-Encoding</span><span>:</span> <span class="string">deflate</span></span>
|
||||
<span class="line"><span class="string">Content-Type</span><span>:</span> <span class="string">text/html; charset=utf-8</span></span>
|
||||
<span class="line section-header">[Asserts]</span>
|
||||
<span class="line"><span class="query-type">body</span> <span class="predicate-type">startsWith</span> <span class="string">"Hello"</span></span>
|
||||
<span class="line"><span class="query-type">bytes</span> <span class="predicate-type">startsWith</span> hex,<span class="hex">48656c6c6f</span>;</span>
|
||||
<span class="line"><span class="query-type">sha256</span> <span class="predicate-type">==</span> hex,<span class="hex">7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069</span>;</span>
|
||||
<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 class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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 class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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 class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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 class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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>
|
||||
<span class="line"><span class="string">Content-Encoding</span><span>:</span> <span class="string">br</span></span>
|
||||
<span class="line"><span class="string">Content-Type</span><span>:</span> <span class="string">text/html; charset=utf-8</span></span>
|
||||
<span class="line section-header">[Asserts]</span>
|
||||
<span class="line"><span class="query-type">body</span> <span class="predicate-type">startsWith</span> <span class="string">"Hello"</span></span>
|
||||
<span class="line"><span class="query-type">bytes</span> <span class="predicate-type">startsWith</span> hex,<span class="hex">48656c6c6f</span>;</span>
|
||||
<span class="line"><span class="query-type">sha256</span> <span class="predicate-type">==</span> hex,<span class="hex">7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069</span>;</span>
|
||||
<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 class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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 class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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 class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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="comment"># Test a large brotli compressed body:</span>
|
||||
<span class="line"><span class="method">GET</span> <span class="url">http://localhost:8000/compressed/brotli_large</span></span>
|
||||
<span class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<span class="line"><span class="version">HTTP/1.0</span> <span class="number">200</span></span>
|
||||
<span class="line"><span class="string">Content-Encoding</span><span>:</span> <span class="string">br</span></span>
|
||||
<span class="line"><span class="string">Content-Type</span><span>:</span> <span class="string">image/jpeg</span></span>
|
||||
<span class="line section-header">[Asserts]</span>
|
||||
<span class="line"><span class="query-type">bytes</span> <span class="predicate-type">startsWith</span> hex,<span class="hex">ffd8ffe0</span>;</span> <span class="comment"># JPEG magic number</span>
|
||||
<span class="line">file,<span class="filename">cat.jpg</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 class="line section-header">[Options]</span>
|
||||
<span class="line"><span class="string">compressed</span><span>:</span> <span class="boolean">true</span></span>
|
||||
</span><span class="response"><span class="line"></span>
|
||||
<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>
|
||||
<span class="line"><span class="string">Content-Encoding</span><span>:</span> <span class="string">br, identity</span></span>
|
||||
<span class="line"><span class="string">Content-Type</span><span>:</span> <span class="string">text/html; charset=utf-8</span></span>
|
||||
<span class="line section-header">[Asserts]</span>
|
||||
<span class="line"><span class="query-type">body</span> <span class="predicate-type">startsWith</span> <span class="string">"Hello"</span></span>
|
||||
<span class="line"><span class="query-type">bytes</span> <span class="predicate-type">startsWith</span> hex,<span class="hex">48656c6c6f</span>;</span>
|
||||
<span class="line"><span class="query-type">sha256</span> <span class="predicate-type">==</span> hex,<span class="hex">7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069</span>;</span>
|
||||
<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></code></pre>
|
212
integration/tests_ok/option_compressed.hurl
Normal file
212
integration/tests_ok/option_compressed.hurl
Normal file
@ -0,0 +1,212 @@
|
||||
# Uncompressed body tests:
|
||||
# ---------------------------
|
||||
# --compressed has no effect on non compressed.
|
||||
|
||||
GET http://localhost:8000/compressed/none
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
Content-Length: 12
|
||||
Content-Type: text/html; charset=utf-8
|
||||
[Asserts]
|
||||
body startsWith "Hello"
|
||||
bytes startsWith hex,48656c6c6f;
|
||||
sha256 == hex,7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069;
|
||||
md5 == hex,ed076287532e86365e841e92bfc50d8c;
|
||||
```Hello World!```
|
||||
|
||||
GET http://localhost:8000/compressed/none
|
||||
[Options]
|
||||
compressed: false
|
||||
|
||||
HTTP/1.0 200
|
||||
Content-Length: 12
|
||||
Content-Type: text/html; charset=utf-8
|
||||
[Asserts]
|
||||
body startsWith "Hello"
|
||||
bytes startsWith hex,48656c6c6f;
|
||||
sha256 == hex,7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069;
|
||||
md5 == hex,ed076287532e86365e841e92bfc50d8c;
|
||||
```Hello World!```
|
||||
|
||||
|
||||
# Test base64 implicit body:
|
||||
GET http://localhost:8000/compressed/none
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
base64,SGVsbG8gV29ybGQh;
|
||||
|
||||
# Test hex implicit body:
|
||||
GET http://localhost:8000/compressed/none
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
hex,48656c6c6f20576f726c6421;
|
||||
|
||||
# Test file implicit body:
|
||||
GET http://localhost:8000/compressed/none
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
file,hello.txt;
|
||||
|
||||
|
||||
# GZip compressed body tests:
|
||||
# ---------------------------
|
||||
|
||||
GET http://localhost:8000/compressed/gzip
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
Content-Length: 32
|
||||
Content-Encoding: gzip
|
||||
Content-Type: text/html; charset=utf-8
|
||||
[Asserts]
|
||||
body startsWith "Hello"
|
||||
bytes startsWith hex,48656c6c6f;
|
||||
sha256 == hex,7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069;
|
||||
md5 == hex,ed076287532e86365e841e92bfc50d8c;
|
||||
```Hello World!```
|
||||
|
||||
# Test base64 implicit body:
|
||||
GET http://localhost:8000/compressed/gzip
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
base64,SGVsbG8gV29ybGQh;
|
||||
|
||||
# Test hex implicit body:
|
||||
GET http://localhost:8000/compressed/gzip
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
hex,48656c6c6f20576f726c6421;
|
||||
|
||||
# Test file implicit body:
|
||||
GET http://localhost:8000/compressed/gzip
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
file,hello.txt;
|
||||
|
||||
|
||||
# ZLib compressed body tests:
|
||||
# ---------------------------
|
||||
|
||||
GET http://localhost:8000/compressed/zlib
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
Content-Length: 20
|
||||
Content-Encoding: deflate
|
||||
Content-Type: text/html; charset=utf-8
|
||||
[Asserts]
|
||||
body startsWith "Hello"
|
||||
bytes startsWith hex,48656c6c6f;
|
||||
sha256 == hex,7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069;
|
||||
md5 == hex,ed076287532e86365e841e92bfc50d8c;
|
||||
```Hello World!```
|
||||
|
||||
# Test base64 implicit body:
|
||||
GET http://localhost:8000/compressed/zlib
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
base64,SGVsbG8gV29ybGQh;
|
||||
|
||||
# Test hex implicit body:
|
||||
GET http://localhost:8000/compressed/zlib
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
hex,48656c6c6f20576f726c6421;
|
||||
|
||||
# Test file implicit body:
|
||||
GET http://localhost:8000/compressed/zlib
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
file,hello.txt;
|
||||
|
||||
|
||||
# Brotli compressed body tests:
|
||||
# ---------------------------
|
||||
|
||||
GET http://localhost:8000/compressed/brotli
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
Content-Length: 17
|
||||
Content-Encoding: br
|
||||
Content-Type: text/html; charset=utf-8
|
||||
[Asserts]
|
||||
body startsWith "Hello"
|
||||
bytes startsWith hex,48656c6c6f;
|
||||
sha256 == hex,7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069;
|
||||
md5 == hex,ed076287532e86365e841e92bfc50d8c;
|
||||
```Hello World!```
|
||||
|
||||
# Test base64 implicit body:
|
||||
GET http://localhost:8000/compressed/brotli
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
base64,SGVsbG8gV29ybGQh;
|
||||
|
||||
# Test hex implicit body:
|
||||
GET http://localhost:8000/compressed/brotli
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
hex,48656c6c6f20576f726c6421;
|
||||
|
||||
# Test file implicit body:
|
||||
GET http://localhost:8000/compressed/brotli
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
file,hello.txt;
|
||||
|
||||
# Test a large brotli compressed body:
|
||||
GET http://localhost:8000/compressed/brotli_large
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
Content-Encoding: br
|
||||
Content-Type: image/jpeg
|
||||
[Asserts]
|
||||
bytes startsWith hex,ffd8ffe0; # JPEG magic number
|
||||
file,cat.jpg;
|
||||
|
||||
GET http://localhost:8000/compressed/brotli_identity
|
||||
[Options]
|
||||
compressed: true
|
||||
|
||||
HTTP/1.0 200
|
||||
Content-Length: 17
|
||||
Content-Encoding: br, identity
|
||||
Content-Type: text/html; charset=utf-8
|
||||
[Asserts]
|
||||
body startsWith "Hello"
|
||||
bytes startsWith hex,48656c6c6f;
|
||||
sha256 == hex,7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069;
|
||||
md5 == hex,ed076287532e86365e841e92bfc50d8c;
|
||||
```Hello World!```
|
1
integration/tests_ok/option_compressed.json
Normal file
1
integration/tests_ok/option_compressed.json
Normal file
File diff suppressed because one or more lines are too long
1
integration/tests_ok/option_compressed.out
Normal file
1
integration/tests_ok/option_compressed.out
Normal file
@ -0,0 +1 @@
|
||||
Hello World!
|
@ -342,7 +342,7 @@ fn main() {
|
||||
{
|
||||
// By default, we output the body response bytes of the last entry
|
||||
if let Some(entry_result) = hurl_result.entries.last() {
|
||||
if let Some(response) = entry_result.response.clone() {
|
||||
if let Some(response) = &entry_result.response {
|
||||
let mut output = vec![];
|
||||
|
||||
// If include options is set, we output the HTTP response headers
|
||||
@ -357,7 +357,7 @@ fn main() {
|
||||
}
|
||||
output.append(&mut "\n".to_string().into_bytes());
|
||||
}
|
||||
let body = if cli_options.compressed {
|
||||
let mut body = if entry_result.compressed {
|
||||
match response.uncompress_body() {
|
||||
Ok(bytes) => bytes,
|
||||
Err(e) => {
|
||||
@ -377,9 +377,9 @@ fn main() {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
response.body
|
||||
response.body.clone()
|
||||
};
|
||||
output.append(&mut body.clone());
|
||||
output.append(&mut body);
|
||||
let result = write_output(&output, &cli_options.output);
|
||||
unwrap_or_exit(result, EXIT_ERROR_UNDEFINED, &base_logger);
|
||||
} else {
|
||||
|
@ -145,6 +145,7 @@ HTTP/1.0 200
|
||||
assert: true,
|
||||
}],
|
||||
time_in_ms: 0,
|
||||
compressed: false,
|
||||
}],
|
||||
time_in_ms: 230,
|
||||
success: true,
|
||||
@ -185,6 +186,7 @@ HTTP/1.0 200
|
||||
assert: false,
|
||||
}],
|
||||
time_in_ms: 0,
|
||||
compressed: false,
|
||||
}],
|
||||
time_in_ms: 230,
|
||||
success: true,
|
||||
|
@ -59,11 +59,11 @@ impl HurlResult {
|
||||
pub struct EntryResult {
|
||||
pub request: Option<http::Request>,
|
||||
pub response: Option<http::Response>,
|
||||
//pub captures: Vec<(String, Value)>,
|
||||
pub captures: Vec<CaptureResult>,
|
||||
pub asserts: Vec<AssertResult>,
|
||||
pub errors: Vec<Error>,
|
||||
pub time_in_ms: u128,
|
||||
pub compressed: bool, // The entry has been executed with `--compressed` option
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
|
@ -52,6 +52,7 @@ pub fn run(
|
||||
asserts: vec![],
|
||||
errors: vec![error],
|
||||
time_in_ms: 0,
|
||||
compressed: client_options.compressed,
|
||||
}];
|
||||
}
|
||||
};
|
||||
@ -103,6 +104,7 @@ pub fn run(
|
||||
assert: false,
|
||||
}],
|
||||
time_in_ms: 0,
|
||||
compressed: client_options.compressed,
|
||||
}];
|
||||
}
|
||||
};
|
||||
@ -128,6 +130,7 @@ pub fn run(
|
||||
asserts: vec![],
|
||||
errors: vec![e],
|
||||
time_in_ms,
|
||||
compressed: client_options.compressed,
|
||||
}];
|
||||
}
|
||||
},
|
||||
@ -179,6 +182,7 @@ pub fn run(
|
||||
asserts,
|
||||
errors,
|
||||
time_in_ms,
|
||||
compressed: client_options.compressed,
|
||||
};
|
||||
entry_results.push(entry_result);
|
||||
}
|
||||
@ -247,6 +251,10 @@ pub fn get_entry_options(
|
||||
client_options.cacert_file = Some(option.filename.value.clone());
|
||||
logger.debug(format!("cacert: {}", option.filename.value).as_str());
|
||||
}
|
||||
EntryOption::Compressed(option) => {
|
||||
client_options.compressed = option.value;
|
||||
logger.debug(format!("compressed: {}", option.value).as_str());
|
||||
}
|
||||
EntryOption::Insecure(option) => {
|
||||
client_options.insecure = option.value;
|
||||
logger.debug(format!("insecure: {}", option.value).as_str());
|
||||
|
@ -668,6 +668,7 @@ pub struct Variable {
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum EntryOption {
|
||||
CaCertificate(CaCertificateOption),
|
||||
Compressed(CompressedOption),
|
||||
Insecure(InsecureOption),
|
||||
FollowLocation(FollowLocationOption),
|
||||
MaxRedirect(MaxRedirectOption),
|
||||
@ -675,6 +676,16 @@ pub enum EntryOption {
|
||||
VeryVerbose(VeryVerboseOption),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CompressedOption {
|
||||
pub line_terminators: Vec<LineTerminator>,
|
||||
pub space0: Whitespace,
|
||||
pub space1: Whitespace,
|
||||
pub space2: Whitespace,
|
||||
pub value: bool,
|
||||
pub line_terminator0: LineTerminator,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct InsecureOption {
|
||||
pub line_terminators: Vec<LineTerminator>,
|
||||
|
@ -233,6 +233,7 @@ impl Htmlable for EntryOption {
|
||||
fn to_html(&self) -> String {
|
||||
match self {
|
||||
EntryOption::CaCertificate(option) => option.to_html(),
|
||||
EntryOption::Compressed(option) => option.to_html(),
|
||||
EntryOption::Insecure(option) => option.to_html(),
|
||||
EntryOption::FollowLocation(option) => option.to_html(),
|
||||
EntryOption::MaxRedirect(option) => option.to_html(),
|
||||
@ -242,6 +243,23 @@ impl Htmlable for EntryOption {
|
||||
}
|
||||
}
|
||||
|
||||
impl Htmlable for CompressedOption {
|
||||
fn to_html(&self) -> String {
|
||||
let mut buffer = String::from("");
|
||||
add_line_terminators(&mut buffer, self.line_terminators.clone());
|
||||
buffer.push_str("<span class=\"line\">");
|
||||
buffer.push_str(self.space0.to_html().as_str());
|
||||
buffer.push_str("<span class=\"string\">compressed</span>");
|
||||
buffer.push_str(self.space1.to_html().as_str());
|
||||
buffer.push_str("<span>:</span>");
|
||||
buffer.push_str(self.space2.to_html().as_str());
|
||||
buffer.push_str(format!("<span class=\"boolean\">{}</span>", self.value).as_str());
|
||||
buffer.push_str("</span>");
|
||||
buffer.push_str(self.line_terminator0.to_html().as_str());
|
||||
buffer
|
||||
}
|
||||
}
|
||||
|
||||
impl Htmlable for InsecureOption {
|
||||
fn to_html(&self) -> String {
|
||||
let mut buffer = String::from("");
|
||||
|
@ -345,6 +345,7 @@ fn option(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
choice(
|
||||
vec![
|
||||
option_cacert,
|
||||
option_compressed,
|
||||
option_insecure,
|
||||
option_follow_location,
|
||||
option_max_redirect,
|
||||
@ -377,6 +378,28 @@ fn option_cacert(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
Ok(EntryOption::CaCertificate(option))
|
||||
}
|
||||
|
||||
fn option_compressed(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
try_literal("compressed", reader)?;
|
||||
let space1 = zero_or_more_spaces(reader)?;
|
||||
try_literal(":", reader)?;
|
||||
let space2 = zero_or_more_spaces(reader)?;
|
||||
let value = nonrecover(boolean, reader)?;
|
||||
let line_terminator0 = line_terminator(reader)?;
|
||||
|
||||
let option = CompressedOption {
|
||||
line_terminators,
|
||||
space0,
|
||||
space1,
|
||||
space2,
|
||||
value,
|
||||
line_terminator0,
|
||||
};
|
||||
|
||||
Ok(EntryOption::Compressed(option))
|
||||
}
|
||||
|
||||
fn option_insecure(reader: &mut Reader) -> ParseResult<'static, EntryOption> {
|
||||
let line_terminators = optional_line_terminators(reader)?;
|
||||
let space0 = zero_or_more_spaces(reader)?;
|
||||
|
@ -819,6 +819,7 @@ impl Tokenizable for EntryOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
match self {
|
||||
EntryOption::CaCertificate(option) => option.tokenize(),
|
||||
EntryOption::Compressed(option) => option.tokenize(),
|
||||
EntryOption::Insecure(option) => option.tokenize(),
|
||||
EntryOption::FollowLocation(option) => option.tokenize(),
|
||||
EntryOption::MaxRedirect(option) => option.tokenize(),
|
||||
@ -849,6 +850,27 @@ impl Tokenizable for CaCertificateOption {
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for CompressedOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
tokens.append(
|
||||
&mut self
|
||||
.line_terminators
|
||||
.iter()
|
||||
.flat_map(|e| e.tokenize())
|
||||
.collect(),
|
||||
);
|
||||
tokens.append(&mut self.space0.tokenize());
|
||||
tokens.push(Token::String("compressed".to_string()));
|
||||
tokens.append(&mut self.space1.tokenize());
|
||||
tokens.push(Token::Colon(String::from(":")));
|
||||
tokens.append(&mut self.space2.tokenize());
|
||||
tokens.push(Token::Boolean(self.value.to_string()));
|
||||
tokens.append(&mut self.line_terminator0.tokenize());
|
||||
tokens
|
||||
}
|
||||
}
|
||||
|
||||
impl Tokenizable for InsecureOption {
|
||||
fn tokenize(&self) -> Vec<Token> {
|
||||
let mut tokens: Vec<Token> = vec![];
|
||||
|
Loading…
Reference in New Issue
Block a user