c-ameron / response-page

Get HTTP Response Status Codes, running on Cloudflare workers

Home Page:https://response.page

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

response.page is an easy to use service that returns HTTP response status codes, running on Cloudflare workers.

  • You can request any HTTP status codes between 200-599 (see response codes)
  • Have a custom status text
  • Receive the response as either text or JSON
  • Custom headers in the response
  • Custom redirect
  • Sleep delay
  • Responds to GET, HEAD, POST, PUT, PATCH, DELETE and OPTIONS methods

You can check out the code at https://github.com/c-ameron/response-page

How to use

Request to https://response.page/status/<status> and get the HTTP status as a response.

JSON Response

To receive JSON as a response, either include the Accept: application/json header, or the format=json query parameter

$ curl https://response.page/status/200?format=json
{"status":200,"statusText":"OK"}

Custom Status Text

By default, it will use the official (and some unofficial) status codes and text in the table above. If you would like to override this, use the statustext query parameter.

$ curl -G --data-urlencode "statustext=custom status text!" https://response.page/status/200
custom status text!

Custom Response Code

You can request any status code between 200 - 599. Simply change the path in /status/<number>. By default you will get an empty status text, so feel free to combine it with the custom statustext option as well.

$ curl -G --data-urlencode "statustext=543: custom error" https://response.page/status/543
543: custom error

Custom Response Headers

Any headers with the prefix x-response- will be returned in the response.

$ curl -H 'x-response-custom-header: foo' -H 'x-response-another-custom-header: bar' https://response.page/status/200 -v

> GET /status/200 HTTP/2
> Host: response.page
> user-agent: curl/7.86.0
> accept: */*
> x-response-custom-header: foo
> x-response-another-custom-header: bar


< HTTP/2 200
< date: Fri, 18 Nov 2022 19:02:24 GMT
< content-type: text/plain
< content-length: 7
< another-custom-header: bar
< custom-header: foo

200: OK

Sleep delay

You can have the response be delayed by using the sleep query parameter, with the sleep time in ms. There is no enforced upper limit (yet), however Cloudflare suggest the limit is around 30s

$ time curl https://response.page/status/200?sleep=5000
200: OK
real	0m5.143s

Custom Redirect

For any 3xx status requested, by default it will return to https://response.page/status/200. However, if you'd like to change this, add the location: header in your request.

curl -H 'location: https://cameron.ci' https://response.page/status/302 -v

> GET /status/302 HTTP/2
> Host: response.page
> user-agent: curl/7.86.0
> accept: */*
> location: https://cameron.ci

< location: https://cameron.ci

302: Found

Response Codes

By default, this service returns all official HTTP status codes between 200 and 599, and some unofficial codes. You can also create your own custom response status (see Instructions).

Status Code Status Text
200 OK
201 Created
202 Accepted
203 Non-Authoritative Information
204 No Content
205 Reset Content
206 Partial Content
207 Multi-Status
208 Already Reported
226 IM Used
301 Moved Permanently
302 Found
303 See Other
304 Not Modified
305 Use Proxy Deprecated
306 unused
307 Temporary Redirect
308 Permanent Redirect
400 Bad Request
401 Unauthorized
402 Payment Required Experimental
403 Forbidden
404 Not Found
405 Method Not Allowed
406 Not Acceptable
407 Proxy Authentication Required
408 Request Timeout
409 Conflict
410 Gone
411 Length Required
412 Precondition Failed
413 Payload Too Large
414 URI Too Long
415 Unsupported Media Type
416 Range Not Satisfiable
417 Expectation Failed
418 I'm a teapot
419 Page Expired
420 Enhance Your Calm
421 Misdirected Request
422 Unprocessable Entity
423 Locked
424 Failed Dependency
425 Too Early Experimental
426 Upgrade Required
428 Precondition Required
429 Too Many Requests
430 Request Header Fields Too Large
431 Request Header Fields Too Large
440 Login Time-out
444 No Response
450 Blocked by Windows Parental Controls
451 Unavailable For Legal Reasons
460
463
494 Request header too large
495 SSL Certificate Error
496 SSL Certificate Required
497 HTTP Request Sent to HTTPS Port
498 Invalid Token
499 Client Closed Request
500 Internal Server Error
501 Not Implemented
502 Bad Gateway
503 Service Unavailable
504 Gateway Timeout
505 HTTP Version Not Supported
506 Variant Also Negotiates
507 Insufficient Storage
508 Loop Detected
509 Bandwidth Limit Exceeded
510 Not Extended
511 Network Authentication Required
520 Web Server Returned an Unknown Error
521 Web Server Is Down
522 Connection Timed Out
523 Origin Is Unreachable
524 A Timeout Occurred
525 SSL Handshake Failed
526 Invalid SSL Certificate
527 Railgun Error
530
598 Network read timeout error
599 Network Connect Timeout Error

FAQs

Why don't you support 1xx HTTP status codes?

Unfortunately the Fetch API the workers runtime uses doesn't support returning 1xx responses and only supports returning a response within 200 and 599

I can't get a response body for 204, 205 or 304 status codes

The Fetch API the workers runtime doesn't support having a response body for the 204, 205 and 304 status codes

Why build this?

When writing other Cloudflare workers, I wanted a way to easily check how my code would handle downstream errors, and it was a fun project to open source

Do you log anything?

I keep no logs. Cloudflare does have the ability to live tail logs which may be used in the event of debugging. This contains some basic information about the event (see here)

I've found a bug, would like to request a feature or contribute

Sure! Thank you for you interest. Please create an issue or PR in the Github Repo. Please bare in mind this is a hobby project so I will get back to you as soon as possible.

Fair Use

For now, this is running on the free workers plan which allows 100k requests a day. There is no rate limiting however if the usage gets high I may implement rate limiting.

Similar projects

Both https://httpstat.us and https://httpbin.org allow the ability to receive http response status codes and I'd like to thank them both for inspiration.

About

Get HTTP Response Status Codes, running on Cloudflare workers

https://response.page

License:GNU General Public License v3.0


Languages

Language:HTML 58.3%Language:TypeScript 41.2%Language:JavaScript 0.5%