Skip to content
httpbeginner

HTTP Basics

Methods, status codes and headers

7 questions

By EZ4Code Team

1. What is the common HTTP method for retrieving a resource?

GET
POST
FETCH
READ
Explanation: GET is used to retrieve a resource and should be idempotent with no side effects; POST is used to submit data to create/update a resource and is typically non-idempotent.

2. What do status codes 200, 404, and 500 mean respectively?

Success, resource not found, internal server error
Success, insufficient permissions, server error
Redirect, not found, success
Server error, not found, success
Explanation: 2xx success (200 OK); 4xx client error (404 Not Found); 5xx server error (500 Internal Server Error).

3. What is the difference between status codes 301 and 302?

301 is a permanent redirect; 302 is a temporary redirect
They are exactly the same
301 is temporary, 302 is permanent
Both are client errors
Explanation: 301 Moved Permanently is a permanent redirect (search engines update their index); 302 Found is a temporary redirect; all 3xx are redirects.

4. What is the main difference between GET and POST?

GET parameters are in the URL, with length limits and insecure; POST is in the request body, suitable for sensitive/large amounts of data
They are exactly the same
POST parameters are in the URL
GET can transmit data of any size
Explanation: GET parameters are appended to the URL query string, with length limits and exposed in logs; POST places data in the request body, with no typical size limit, and is relatively more secure.

5. HTTP is a stateless protocol; what is commonly used to maintain state?

Cookies and Sessions, or Tokens
TCP connections
IP addresses
Port numbers
Explanation: HTTP itself is stateless; Cookies (client-side) and Sessions (server-side) are commonly used to maintain state; modern solutions also use JWT and other Token schemes.

6. What does the HTTP request header Content-Type do?

Tells the server the media type of the request body (e.g. application/json)
Specifies the response status code
Specifies the request method
Specifies the caching policy
Explanation: Content-Type describes the media type of the request/response body, e.g. application/json, application/x-www-form-urlencoded, multipart/form-data.

7. What is the main difference between HTTPS and HTTP?

HTTPS adds TLS/SSL encryption on top of HTTP, providing confidentiality, integrity, and identity authentication
They are exactly the same
HTTP is more secure than HTTPS
HTTPS is a new version number of HTTP
Explanation: HTTPS = HTTP + TLS/SSL; it prevents eavesdropping and tampering through encryption, and authenticates the server through certificates; the default port is 443 (HTTP 80).