Skip to content

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

http.request.body.raw String

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

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

http.request.body.size Number

The total size of the HTTP request body (in bytes).

http.request.body.form

http.request.body.form Map<Array<String>>

The HTTP request body of a form represented 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:

any(http.request.body.form["username"][*] == "admin")

Example value: {username": ["admin"]}

http.request.body.form.names

http.request.body.form.names Array<String>

The names of the form fields in an HTTP request where the content type is application/x-www-form-urlencoded.

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:

any(http.request.body.form.names[*] == "username")

Example value:

["username"]

http.request.body.form.values

http.request.body.form.values Array<String>

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:

any(http.request.body.form.values[*] == "admin")

Example value:

["admin"]

http.request.body.mime

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

http.request.body.multipart Map<Array<String>>

A Map (or associative array) representation 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

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

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

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

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

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

http.request.body.multipart.filenames Array<Array<String>>

List of filenames for each part in the multipart body.

Example value:

[["file1.txt"], ["photo.jpg"]]