Skip to content

Commit 6a0f7d3

Browse files
committed
8.0.0 doc update.
1 parent c7e20c3 commit 6a0f7d3

34 files changed

Lines changed: 842 additions & 161 deletions

.github/workflows/publish.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,9 @@ jobs:
2525
pip3 install --user -r ./sites/requirements.txt
2626
sudo gem install jekyll
2727
- name: Check style
28-
run: |
29-
cd sites
30-
./check_fmt.sh
28+
run: sites/check_fmt.sh
3129
- name: Build
32-
run: |
33-
cd sites
34-
./build.sh
30+
run: sites/build.sh
3531
- name: Publish
3632
if: github.ref == 'refs/heads/master'
3733
env:

sites/build.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/usr/bin/env bash
22
set -eu
33

4+
original_dir="$(pwd)"
5+
cd "$(dirname "$0")"
6+
47
function echo_step () {
58
echo ''
69
echo -e "\033[32m\033[1m$1...\033[0m"
@@ -39,8 +42,9 @@ python3 build_sitemap.py > hurl.dev/_site/sitemap.txt
3942
echo_step 'Generating feed.xml'
4043
cp hurl.dev/_posts/feed.xml hurl.dev/_site/blog/
4144

45+
sites_dir=$(realpath --relative-to="$original_dir" "$(pwd)")
4246
echo ''
4347
echo 'Run local site'
4448
echo '-------------------'
45-
echo ' Build & watch: jekyll serve --source hurl.dev --destination hurl.dev/_site'
46-
echo ' Static: python3 -m http.server --dir hurl.dev/_site 4000'
49+
echo " Build & watch: jekyll serve --source $sites_dir/hurl.dev --destination $sites_dir/hurl.dev/_site"
50+
echo " Static: python3 -m http.server --dir $sites_dir/hurl.dev/_site 4000"

sites/build_home_samples.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ def make_home_samples():
324324
""",
325325
),
326326
Sample(
327-
name="SSL Certificate",
327+
name="SSL/TLS Certificate",
328328
src="""\
329329
# Check attributes of the SSL certificate
330330
GET https://example.org
@@ -334,6 +334,9 @@ def make_home_samples():
334334
certificate "Issuer" == "C=US, O=Let's Encrypt, CN=R3"
335335
certificate "Expire-Date" daysAfterNow > 15
336336
certificate "Serial-Number" matches /[\\da-f]+/
337+
certificate "Subject-Alt-Name" contains "DNS:example.org"
338+
certificate "Subject-Alt-Name" split "," count == 2
339+
certificate "Value" startsWith "-----BEGIN CERTIFICATE-----"
337340
""",
338341
),
339342
Sample(

sites/hurl.dev/_data/docs.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@
4848
items:
4949
- title: Capturing values
5050
- title: Asserts
51-
- title: Options
52-
- title: Environment
51+
- title: Configuration
52+
- title: All Options
53+
items:
54+
- title: HTTP options
55+
- title: Output options
56+
- title: Report options
57+
- title: Other options
5358
- title: Exit Codes
5459
- title: WWW
5560
- title: See Also
@@ -211,6 +216,7 @@
211216
- title: Cookie capture
212217
- title: Body capture
213218
- title: Bytes capture
219+
- title: RawBytes capture
214220
- title: XPath capture
215221
- title: JSONPath capture
216222
- title: Regex capture
@@ -250,6 +256,7 @@
250256
- title: Cookie assert
251257
- title: Body assert
252258
- title: Bytes assert
259+
- title: RawBytes assert
253260
- title: XPath assert
254261
- title: JSONPath assert
255262
- title: Regex assert
@@ -272,11 +279,11 @@
272279
- title: base64Encode
273280
- title: base64UrlSafeDecode
274281
- title: base64UrlSafeEncode
282+
- title: charsetDecode
275283
- title: count
276284
- title: dateFormat
277285
- title: daysAfterNow
278286
- title: daysBeforeNow
279-
- title: decode
280287
- title: first
281288
- title: htmlEscape
282289
- title: htmlUnescape

sites/hurl.dev/_docs/asserting-response.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ jsonpath "$.cats[0].name" == "Felix"
2626
jsonpath "$.cats[0].lives" == 9
2727
```
2828

29-
Body responses can be encoded by server (see [`Content-Encoding` HTTP header]) but asserts in Hurl files are not
30-
affected by this content compression. All body asserts (`body`, `bytes`, `sha256` etc...) work _after_ content decoding.
29+
Body responses can be encoded by server (see [`Content-Encoding` HTTP header][content-encoding]) but asserts in Hurl files are not
30+
affected by this content compression. All body asserts (`body`, `bytes`, `sha256` etc...) except `rawbytes` work _after_ content decoding.
3131

3232
Finally, body text asserts (`body`, `jsonpath`, `xpath` etc...) are also decoded to strings based on [`Content-Type` header]
3333
so these asserts can be written with usual strings.
@@ -92,6 +92,7 @@ The asserts order in a Hurl file is:
9292
</div>
9393
</div>
9494

95+
9596
## Implicit asserts
9697

9798
### Version - Status
@@ -344,7 +345,7 @@ to specify the root directory of all file nodes.
344345
Optional list of assertions on the HTTP response within an `[Asserts]` section. Assertions can describe checks
345346
on status code, on the received body (or part of it) and on response headers.
346347

347-
Structure of an assert:
348+
__Structure of an explicit assert:__
348349

349350
<div class="schema-container schema-container u-font-size-1 u-font-size-2-sm u-font-size-3-md">
350351
<div class="schema">
@@ -375,6 +376,7 @@ can extract data from
375376
- body:
376377
- [`body`](#body-assert)
377378
- [`bytes`](#bytes-assert)
379+
- [`rawbytes`](#rawbytes-assert)
378380
- [`xpath`](#xpath-assert)
379381
- [`jsonpath`](#jsonpath-assert)
380382
- [`regex`](#regex-assert)
@@ -681,6 +683,25 @@ header "Content-Length" == "12424"
681683
Like `body` assert, `bytes` assert works _after_ content encoding decompression (so the predicates values are not
682684
affected by `Content-Encoding` response header value).
683685

686+
### RawBytes assert
687+
688+
Check the value of the received HTTP response body as a raw bytestream. RawBytes assert consists of the keyword `rawbytes`
689+
followed by a predicate function and value.
690+
691+
```hurl
692+
GET https://example.org/data.bin
693+
HTTP 200
694+
Content-Encoding: gzip
695+
[Asserts]
696+
header "Content-Length" == "32"
697+
rawbytes count == 32 # matches Content-Length (compressed size)
698+
bytes count == 100 # decompressed size is larger
699+
rawbytes startsWith hex,1f8b; # gzip magic bytes
700+
bytes startsWith hex,48656c6c6f; # decompressed content starts with "Hello"
701+
```
702+
703+
Unlike `bytes` assert, `rawbytes` returns the raw bytes _before_ any content decoding. For uncompressed responses, `rawbytes` and `bytes` return the same data.
704+
684705
### XPath assert
685706

686707
Check the value of a [XPath] query on the received HTTP body decoded as a string (using the `charset` value in the
@@ -972,7 +993,8 @@ duration < 1000 # Check that response time is less than one second
972993
Check the SSL certificate properties. Certificate assert consists of the keyword `certificate`, followed by the
973994
certificate attribute value.
974995

975-
The following attributes are supported: `Subject`, `Issuer`, `Start-Date`, `Expire-Date` and `Serial-Number`.
996+
The following attributes are supported: `Subject`, `Issuer`, `Start-Date`, `Expire-Date`, `Serial-Number`,
997+
`Subject-Alt-Name` and `Value`.
976998

977999
```hurl
9781000
GET https://example.org
@@ -982,6 +1004,9 @@ certificate "Subject" == "CN=example.org"
9821004
certificate "Issuer" == "C=US, O=Let's Encrypt, CN=R3"
9831005
certificate "Expire-Date" daysAfterNow > 15
9841006
certificate "Serial-Number" matches "[0-9af]+"
1007+
certificate "Subject-Alt-Name" contains "DNS:example.org"
1008+
certificate "Subject-Alt-Name" split "," count == 2
1009+
certificate "Value" startsWith "-----BEGIN CERTIFICATE-----"
9851010
```
9861011

9871012
[predicates]: #predicates
@@ -1008,7 +1033,7 @@ certificate "Serial-Number" matches "[0-9af]+"
10081033
[`decode` filter]: {% link _docs/filters.md %}#decode
10091034
[headers implicit asserts]: #headers
10101035
[RFC 3339]: https://www.rfc-editor.org/rfc/rfc3339
1011-
[`Content-Encoding` HTTP header]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
1036+
[content-encoding]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
10121037
[`Content-Type` header]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type
10131038
[`body` assert]: #body-assert
10141039
[`location` filter]: {% link _docs/filters.md %}#location

sites/hurl.dev/_docs/capturing-response.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ HTTP 302
3636
{% endraw %}
3737

3838

39-
Body responses can be encoded by server (see [`Content-Encoding` HTTP header]) but captures in Hurl files are not
40-
affected by this content compression. All body captures (`body`, `bytes`, `sha256` etc...) work _after_ content decoding.
39+
Body responses can be encoded by server (see [`Content-Encoding` HTTP header][content-encoding]) but captures in Hurl files are not
40+
affected by this content compression. All body captures (`body`, `bytes`, `sha256` etc...) except `rawbytes` work _after_ content decoding.
4141

4242
Finally, body text captures (`body`, `jsonpath`, `xpath` etc...) are also decoded to strings based on [`Content-Type` header]
4343
so these queries can be captures as usual strings.
4444

4545

46-
Structure of a capture:
46+
__Structure of a capture:__
4747

4848
<div class="schema-container schema-container u-font-size-2 u-font-size-3-sm">
4949
<div class="schema">
@@ -71,6 +71,7 @@ A query can extract data from
7171
- body:
7272
- [`body`](#body-capture)
7373
- [`bytes`](#bytes-capture)
74+
- [`rawbytes`](#bytes-capture)
7475
- [`xpath`](#xpath-capture)
7576
- [`jsonpath`](#jsonpath-capture)
7677
- [`regex`](#regex-capture)
@@ -198,6 +199,19 @@ my_data: bytes
198199
Like `body` capture, `bytes` capture works _after_ content encoding decompression (so the captured value is not
199200
affected by `Content-Encoding` response header).
200201

202+
### RawBytes capture
203+
204+
Capture the entire body as a raw bytestream from the received HTTP response, _before_ any content decoding.
205+
206+
```hurl
207+
GET https://example.org/data.bin
208+
HTTP 200
209+
[Captures]
210+
raw_data: rawbytes
211+
```
212+
213+
Unlike `bytes` capture, `rawbytes` returns the raw bytes before content encoding decompression. For uncompressed responses, `rawbytes` and `bytes` capture the same data.
214+
201215
### XPath capture
202216

203217
Capture a [XPath] query from the received HTTP body decoded as a string.
@@ -423,7 +437,8 @@ duration_in_ms: duration
423437

424438
Capture the SSL certificate properties. Certificate capture consists of the keyword `certificate`, followed by the certificate attribute value.
425439

426-
The following attributes are supported: `Subject`, `Issuer`, `Start-Date`, `Expire-Date` and `Serial-Number`.
440+
The following attributes are supported: `Subject`, `Issuer`, `Start-Date`, `Expire-Date`, `Serial-Number`,
441+
`Subject-Alt-Name` and `Value`.
427442

428443
```hurl
429444
GET https://example.org
@@ -433,6 +448,8 @@ cert_subject: certificate "Subject"
433448
cert_issuer: certificate "Issuer"
434449
cert_expire_date: certificate "Expire-Date"
435450
cert_serial_number: certificate "Serial-Number"
451+
san: certificate "Serial-Number"
452+
value: certificate "Value"
436453
```
437454

438455
## Redacting Secrets
@@ -469,3 +486,5 @@ pass: header "token" redact
469486
[`--secret` option]: {% link _docs/templates.md %}#secrets
470487
[MD5]: https://en.wikipedia.org/wiki/MD5
471488
[SHA-256]: https://en.wikipedia.org/wiki/SHA-2
489+
[content-encoding]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding
490+
[`Content-Type` header]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type

sites/hurl.dev/_docs/entry.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ HTTP 200
7777

7878
### Cookie storage
7979

80-
Requests in the same Hurl file share the cookie storage, enabling, for example, session based scenario.
80+
By default, requests in the same Hurl file share cookie storage, enabling session-based scenario. The shared cookie store can
81+
be disabled with [`--no-cookie-store`] option.
8182

8283
### Redirects
8384

@@ -260,3 +261,4 @@ For complete reference, below is a diagram for the executed entries.
260261
[`repeat`]: {% link _docs/manual.md %}#repeat
261262
[`redirects` query]: {% link _docs/asserting-response.md %}#redirects-assert
262263
[`url` query]: {% link _docs/asserting-response.md %}#url-assert
264+
[`--no-coookie-store`]: {% link _docs/manual.md %}#no-cookie-store

sites/hurl.dev/_docs/filters.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ jsonpath "$.books" count == 12
7171
| [base64Encode](#base64encode) | Encodes bytes into [Base64 encoded string]. | bytes | string |
7272
| [base64UrlSafeDecode](#base64urlsafedecode) | Decodes a Base64 encoded string into bytes (using [Base64 URL safe encoding]). | string | bytes |
7373
| [base64UrlSafeEncode](#base64urlsafeencode) | Encodes bytes into Base64 encoded string (using [Base64 URL safe encoding]). | bytes | string |
74+
| [charsetDecode](#charsetdecode) | Decodes bytes to string using a charset encoding. | bytes | string |
7475
| [count](#count) | Counts the number of items in a collection. | collection | number |
7576
| [dateFormat](#dateformat) | Formats a date to a string given [a specification format]. | date | string |
7677
| [daysAfterNow](#daysafternow) | Returns the number of days between now and a date in the future. | date | number |
7778
| [daysBeforeNow](#daysbeforenow) | Returns the number of days between now and a date in the past. | date | number |
78-
| [decode](#decode) | Decodes bytes to string using encoding. | bytes | string |
7979
| [first](#first) | Returns the first element from a collection. | collection | any |
8080
| [htmlEscape](#htmlescape) | Converts the characters `&`, `<` and `>` to HTML-safe sequence. | string | string |
8181
| [htmlUnescape](#htmlunescape) | Converts all named and numeric character references (e.g. `&gt;`, `&#62;`, `&#x3e;`) to the corresponding Unicode characters. | string | string |
@@ -143,6 +143,23 @@ HTTP 200
143143
bytes base64UrlSafeEncode == "PDw_Pz8-Pg"
144144
```
145145

146+
### charsetDecode
147+
148+
Decodes bytes to string using a charset encoding. Encoding labels are defined in [Encoding Standard].
149+
150+
```hurl
151+
# The 'Content-Type' HTTP response header does not precise the charset 'gb2312'
152+
# so body must be decoded explicitly by Hurl before processing any text based assert
153+
GET https://example.org/hello_china
154+
HTTP 200
155+
[Asserts]
156+
header "Content-Type" == "text/html"
157+
# Content-Type has no encoding clue, we must decode ourselves the body response.
158+
bytes charsetDecode "gb2312" xpath "string(//body)" == "你好世界"
159+
```
160+
161+
When the encoding is UTF-8 (i.e. `charsetDecode "utf-8"`), [an `utf8Decode` filter] can be used instead.
162+
146163
### count
147164

148165
Counts the number of items in a collection.
@@ -189,21 +206,6 @@ HTTP 200
189206
certificate "Start-Date" daysBeforeNow < 100
190207
```
191208

192-
### decode
193-
194-
Decodes bytes to string using encoding. Encoding labels are defined in [Encoding Standard].
195-
196-
```hurl
197-
# The 'Content-Type' HTTP response header does not precise the charset 'gb2312'
198-
# so body must be decoded explicitly by Hurl before processing any text based assert
199-
GET https://example.org/hello_china
200-
HTTP 200
201-
[Asserts]
202-
header "Content-Type" == "text/html"
203-
# Content-Type has no encoding clue, we must decode ourselves the body response.
204-
bytes decode "gb2312" xpath "string(//body)" == "你好世界"
205-
```
206-
207209
### first
208210

209211
Returns the first element from a collection.
@@ -475,7 +477,6 @@ HTTP 200
475477
bytes decode "gb2312" xpath "string(//body)" == "你好世界"
476478
```
477479

478-
479480
[Captures]: {% link _docs/capturing-response.md %}
480481
[asserts]: {% link _docs/asserting-response.md %}
481482
[RFC3986]: https://www.rfc-editor.org/rfc/rfc3986
@@ -485,3 +486,5 @@ bytes decode "gb2312" xpath "string(//body)" == "你好世界"
485486
[Base64 encoded string]: https://datatracker.ietf.org/doc/html/rfc4648#section-4
486487
[Base64 URL safe encoding]: https://datatracker.ietf.org/doc/html/rfc4648#section-5
487488
[Encoding Standard]: https://encoding.spec.whatwg.org/#concept-encoding-get
489+
[an `utf8Decode` filter]: {% link _docs/filters.md %}#utf8decode
490+
[an `utf8Encode` filter]: {% link _docs/filters.md %}#utf8encode

0 commit comments

Comments
 (0)