HTTP request body fields
The Rules language includes fields that represent properties of an HTTP request body. Many of these return arrays containing the respective values.
The Cloudflare Rules language supports these HTTP body fields.
http.request.body.raw
String
Represents the unaltered HTTP request body.
When the value of http.request.body.truncated
is true, the return value may be truncated.
- Decoding: no decoding performed
- Whitespace: preserved
- Non-ASCII: preserved
http.request.body.truncated
Boolean
Indicates whether the HTTP request body is truncated.
When true, http.request.body
fields may not contain all of the HTTP request body.
http.request.body.size
Number
The total size of the HTTP request body (in bytes).
http.request.body.form
Map<Array<String>>
Represents the HTTP request body of a form as a Map (or associative array). Populated when the Content-Type header is application/x-www-form-urlencoded
.
The values are not pre-processed and retain the original case used in the request.
When a field repeats, then the array contains multiple items in the order they are in the request.
The return value may be truncated if http.request.body.truncated
is true.
- Decoding: no decoding performed
- Whitespace: preserved
- Non-ASCII: preserved
Example:
Example value:
{username": ["admin"]}
http.request.body.form.names
Array<String>
Represents the names of the form fields in an HTTP request where the content type is application/x-www-form-urlencoded
.
The names are not pre-processed and retain the original case used in the request. They are listed in the same order as in the request.
Duplicate names are listed multiple times.
The return value may be truncated if http.request.body.truncated
is true.
- Decoding: no decoding performed
- Whitespace: preserved
- Non-ASCII: preserved
Example:
Example value:
["username"]
http.request.body.form.values
Array<String>
Represents the values of the form fields in an HTTP request where the content type is application/x-www-form-urlencoded
.
The values are not pre-processed and retain the original case used in the request. They are listed in the same order as in the request.
Duplicated values are listed multiple times.
The return value may be truncated if http.request.body.truncated
is true.
- Decoding: no decoding performed
- Whitespace: preserved
- Non-ASCII: preserved
Example:
Example value:
["admin"]
http.request.body.mime
String
The MIME type of the request detected from the request body.
Supports the most common MIME types of the following general categories: video, audio, image, application, text.
Example:
image/jpeg
This field is available on all Cloudflare plans.
http.request.body.multipart
Map<Array<String>>
A Map (or associative array) of multipart names to multipart values in the request body.
Example value:
{"username": ["alice_doe"], "picture": [<binary_content_of_file>]}
http.request.body.multipart.names
Array<Array<String>>
List of multipart names for every part in the multipart body.
Example value:
[["username"], ["picture"]]
Example:
any(http.request.body.multipart.names[*][0] == "picture")
http.request.body.multipart.values
Array<String>
List of multipart values for every part in the multipart body.
Example value:
["alice_doe", <binary_content_of_file>]
http.request.body.multipart.content_types
Array<Array<String>>
List of Content-Type
headers for each part in the multipart body.
Example value:
[["text/plain"], ["image/jpeg"]]
Example:
any(http.request.body.multipart.content_types[*][0] == "application/octet-stream")
http.request.body.multipart.content_dispositions
Array<Array<String>>
List of Content-Disposition
headers for each part in the multipart body.
Example value:
[["form-data; name=\"username\"], ["form-data;name=\"picture\"]]
http.request.body.multipart.content_transfer_encodings
Array<Array<String>>
List of Content-Transfer-Encoding
headers for each part in the multipart body.
Example value:
[["quoted-printable"], ["quoted-printable"]]
http.request.body.multipart.filenames
Array<Array<String>>
List of filenames for each part in the multipart body.
Example value:
[["file1.txt"], ["photo.jpg"]]