Skip to content

Commit 084f590

Browse files
committed
8.0.0 doc update.
1 parent c7e20c3 commit 084f590

15 files changed

Lines changed: 359 additions & 145 deletions

File tree

.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/hurl.dev/_data/docs.yml

Lines changed: 8 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
@@ -272,11 +277,11 @@
272277
- title: base64Encode
273278
- title: base64UrlSafeDecode
274279
- title: base64UrlSafeEncode
280+
- title: charsetDecode
275281
- title: count
276282
- title: dateFormat
277283
- title: daysAfterNow
278284
- title: daysBeforeNow
279-
- title: decode
280285
- title: first
281286
- title: htmlEscape
282287
- title: htmlUnescape

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

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jsonpath "$.cats[0].lives" == 9
2727
```
2828

2929
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.
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.
@@ -681,6 +681,25 @@ header "Content-Length" == "12424"
681681
Like `body` assert, `bytes` assert works _after_ content encoding decompression (so the predicates values are not
682682
affected by `Content-Encoding` response header value).
683683

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

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

975-
The following attributes are supported: `Subject`, `Issuer`, `Start-Date`, `Expire-Date` and `Serial-Number`.
994+
The following attributes are supported: `Subject`, `Issuer`, `Start-Date`, `Expire-Date`, `Serial-Number`, and `Subject-Alt-Name`.
976995

977996
```hurl
978997
GET https://example.org
@@ -982,6 +1001,8 @@ certificate "Subject" == "CN=example.org"
9821001
certificate "Issuer" == "C=US, O=Let's Encrypt, CN=R3"
9831002
certificate "Expire-Date" daysAfterNow > 15
9841003
certificate "Serial-Number" matches "[0-9af]+"
1004+
certificate "Subject-Alt-Name" contains "DNS:example.org"
1005+
certificate "Subject-Alt-Name" split "," count == 2
9851006
```
9861007

9871008
[predicates]: #predicates

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ HTTP 302
3737

3838

3939
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.
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.
@@ -198,6 +198,19 @@ my_data: bytes
198198
Like `body` capture, `bytes` capture works _after_ content encoding decompression (so the captured value is not
199199
affected by `Content-Encoding` response header).
200200

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

203216
Capture a [XPath] query from the received HTTP body decoded as a string.

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)