You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
+
684
703
### XPath assert
685
704
686
705
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
972
991
Check the SSL certificate properties. Certificate assert consists of the keyword `certificate`, followed by the
973
992
certificate attribute value.
974
993
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`.
Copy file name to clipboardExpand all lines: sites/hurl.dev/_docs/capturing-response.md
+14-1Lines changed: 14 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ HTTP 302
37
37
38
38
39
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.
40
+
affected by this content compression. All body captures (`body`, `bytes`, `sha256` etc...) except `rawbytes`work _after_ content decoding.
41
41
42
42
Finally, body text captures (`body`, `jsonpath`, `xpath` etc...) are also decoded to strings based on [`Content-Type` header]
43
43
so these queries can be captures as usual strings.
@@ -198,6 +198,19 @@ my_data: bytes
198
198
Like `body` capture, `bytes` capture works _after_ content encoding decompression (so the captured value is not
199
199
affected by `Content-Encoding` response header).
200
200
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
+
201
214
### XPath capture
202
215
203
216
Capture a [XPath] query from the received HTTP body decoded as a string.
|[charsetDecode](#charsetdecode)| Decodes bytes to string using a charset encoding. | bytes | string |
74
75
|[count](#count)| Counts the number of items in a collection. | collection | number |
75
76
|[dateFormat](#dateformat)| Formats a date to a string given [a specification format]. | date | string |
76
77
|[daysAfterNow](#daysafternow)| Returns the number of days between now and a date in the future. | date | number |
77
78
|[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 |
79
79
|[first](#first)| Returns the first element from a collection. | collection | any |
80
80
|[htmlEscape](#htmlescape)| Converts the characters `&`, `<` and `>` to HTML-safe sequence. | string | string |
81
81
|[htmlUnescape](#htmlunescape)| Converts all named and numeric character references (e.g. `>`, `>`, `>`) to the corresponding Unicode characters. | string | string |
@@ -143,6 +143,23 @@ HTTP 200
143
143
bytes base64UrlSafeEncode == "PDw_Pz8-Pg"
144
144
```
145
145
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.
0 commit comments