Skip to contents

Some servers do not check a client that does not look like a browser but refuse it outright. Cloudflare's firewall does so with a 403 and its own block page; a real browser is served the resource instead.

Usage

is_block(status, headers, body = NULL)

Arguments

status

The HTTP status code.

headers

The response headers, either as the raw header block (one string, lines separated by \r\n) or as a named list such as curl::parse_headers_list() makes of it.

body

The response body, as a string.

Value

TRUE when the response is Cloudflare's block page: a 403 from server: cloudflare whose body is the "Sorry, you have been blocked" page.

Examples

is_block(403, "HTTP/2 403\r\nserver: cloudflare\r\n\r\n",
         "<html><title>Attention Required! | Cloudflare</title>...")
#> [1] TRUE
is_block(403, "HTTP/2 403\r\nserver: nginx\r\n\r\n", "Forbidden")
#> [1] FALSE