Explore the fundamentals of HTTP status codes and request methods with this quiz designed for beginners in internet technologies. Understand how web servers communicate with clients using well-known codes and methods for effective troubleshooting and web development knowledge.
Which HTTP status code is returned for a successful GET request?
Explanation: The 200 status code indicates that a request has succeeded, typically in response to GET requests. The code 100 means 'Continue', which is used during request headers. 301 is used for permanent redirects, not for indicating success. 404 represents 'Not Found', which signals the requested resource does not exist.
What is the primary use of the HTTP POST method in web applications?
Explanation: The POST method is mainly used to submit data to a web server to create new resources, like submitting a form. Retrieving resources is the main job of the GET method, not POST. Deleting something uses the DELETE method, while updating is typically done with PUT or PATCH.
Which of the following HTTP status codes signals that a URL has been permanently moved to a new location?
Explanation: A 301 status code tells the client that the resource has permanently moved to a new URL. 200 simply shows success, not redirection. 500 indicates a server error, and 202 means 'Accepted' but does not relate to redirection.
If you want to completely replace an existing resource on the server, which HTTP method should you use?
Explanation: The PUT method is designed to completely replace an existing resource with the new data provided in the request. GET fetches resources but does not modify them. DELETE removes resources, and HEAD retrieves header information without the resource body.
Which HTTP status code is most commonly associated with a web page not being found?
Explanation: A 404 status code means 'Not Found' and is returned when the server cannot find the requested resource. 201 means a resource was created, 403 stands for forbidden access, and 418 is a joke code meaning 'I am a teapot.'
Which HTTP method is both safe and idempotent, meaning it can be called multiple times without side effects?
Explanation: GET is both a safe and idempotent method, making it suitable for data retrieval where repeated requests yield the same result. POST can cause changes and is not idempotent. PATCH applies partial modifications, and CONNECT establishes a tunnel, neither of which are safe or idempotent.
If a server refuses a request due to lack of proper authorization, what HTTP status code is typically returned?
Explanation: A 403 status code means 'Forbidden', which is used when the server denies access to a resource even if authentication is provided. The 201 status code indicates creation of a resource, 307 is a temporary redirect, and 101 refers to protocol switching.
Which HTTP method is generally used to apply partial modifications to an existing resource?
Explanation: PATCH is intended to make partial updates to an existing resource. GET is used solely for retrieving resource data. HEAD is similar to GET but fetches only headers, and OPTIONS checks what methods are supported by the server, not for updating resources.
In HTTP, what is the main purpose of the DELETE method?
Explanation: DELETE is intended specifically to remove resources from the server. Retrieving headers is done through the HEAD method. Submitting form data uses POST, while uploading files may use POST or PUT but not DELETE.
HTTP status codes in the 4xx range generally indicate which type of issue?
Explanation: The 4xx range of HTTP status codes signifies client errors, such as bad requests or unauthorized access. Codes in the 2xx range indicate server success. The 5xx series points to server errors, and redirection is handled with 3xx codes.