HTTP status codes

HTTP error codes

What do the browser error codes mean?

Status codes are issued by a server in response to a client's request made to the server. Typically when your browser requests a web page the host server will give the browser an informational response, a success report, a redirection request or an error.


Write a program that outputs what each of these HTTP status codes mean: 400, 401/403, 404. Any other code is an unknown error for the purpose of this program.

Use this boilerplate code as a starting point:

Success Criteria

Remember to add a comment before a subprogram or selection statement to explain its purpose.

Complete the subprogram called `http_status` so that it:

  1. Returns "Bad request" if the status is 400.
  2. Returns "Authentication error" if the status is 401 or 403.
  3. Returns "Not found" if the status code is 404.
  4. Returns "Unknown error" for any other status code.

A typical output from the program when code is 404 would be:

Not found

Knowledge Organiser

Use these resources as a reference to help you meet the success criteria.

Programming guide:


Create the unit tests below to check that your program has met the success criteria.

code = 400

Bad request

code = 401

Authentication error

code = 403

Authentication error

code = 404

Not found

code = 500

Unknown error

Check that you have:

  • Used comments within the code to describe the purpose of subprograms and conditions.
  • Used meaningful identifier names. That means the names of subprograms and variables indicate what they are for.