-
Notifications
You must be signed in to change notification settings - Fork 0
EN_Net_HTTP
HTTP (Hypertext Transfer Protocol) is the protocol used for transmitting data over the web, including HTML, images, and multimedia content. Data transferred via HTTP is unencrypted, making it susceptible to security threats.
Here's how HTTP works:
- A client sends an HTTP request to the server, which includes an HTTP method (GET, POST, etc.) and a URI (Uniform Resource Identifier).
- GET requests data, while POST submits data to the server.
- The server responds with an HTTP message that has a status code (like 200 for success) and the requested content.
- The client processes this content, rendering web pages from files like
HTML, CSS, and JavaScript.
HTTPS (HTTP Secure) encrypts data transfers using SSL (Secure Sockets Layer) or TLS (Transport Layer Security) and verifies server identities with certificates.
The HTTPS process goes as follows:
- A client connects to an HTTPS-protected server using an SSL/TLS-capable browser.
- The server shares its SSL/TLS certificate, which includes a public key and certification authority (CA) details.
- The client authenticates the server's certificate using the CA's public key.
- The client then creates a session key, encrypts it with the server's public key, and sends it over.
- The server decrypts the session key with its private key.
- Encrypted HTTPS communication is now established, securing the data exchange.
- Using HTTPS ensures data privacy and security, protecting against eavesdropping and man-in-the-middle attacks.
HTTP methods are a way for a client to indicate to a web server what kind of behavior it wants. Each method is designed to perform a specific kind of task.
- Mainly used when retrieving information from a server. (Get)
- GET requests are not used to change or create data; they are only used to read data.
- Mainly used when adding resources to the server. (Create)
- Used when a client attempts to create a server resource.
- A POST request sends data to the server and uses the data to create a new resource or update an existing resource.
- It is almost similar to a GET request, but returns only HTTP header information without actual body content. (No Body)
- There is no body in the response.
- It is efficient because you can obtain information about the resource without having to retrieve it.
- Used to update the entire contents of the resource corresponding to a specific URL. (Update)
- If a resource already exists in the URL, a PUT request replaces the resource with a new one. If the resource does not exist, a new resource is created.
- Used to remove specific resources.
- When a DELETE request is successful, it usually does not include data in the response body.
- Used to apply partial changes to the source.
- PATCH requests can be more efficient than PUT requests because they only change part of the request.
- Used to check the type of method supported by the resource.
- The OPTIONS request returns a list of HTTP methods available on the resource along with a header called “Allow”.
- Mainly used for diagnostic purposes.
- TRACE requests are sent from the client to the server and can be used to check whether any changes or additions are made during this process. When the TRACE request reaches the server, the server returns the request as is as the response body.
- Through this, the client can check how the request was processed.
- Mainly used to create network tunnels. The most common example is an SSL tunnel for HTTPS communication.
- When the client uses the CONNECT method, the web server establishes a network connection with the destination server and relays data between the client and the destination server.
HTTP Status Code is a method by which the server delivers the result of request processing to the client in an HTTP response.
This code consists of three digits, and what each means is as follows.
- 1xx (Informational): Indicates that the request has been received and the process is continuing.
-
2xx (Successful): Indicates that the request has been successfully received, understood, and accepted. The most common code is
200 OK, indicating that the request was processed successfully. -
3xx (Redirection): Indicates that the client must take additional action to complete the request. For example,
301 Moved Permanentlyindicates that the URI of the requested resource has changed, and a new URI is provided to the client. -
4xx (Client Error): Indicates that the client's request is incorrect or cannot be completed. The most commonly seen code is
404 Not Found, which is returned when the requested resource cannot be found on the server. -
5xx (Server Error): Indicates that the server failed to process a valid request.
500 Internal Server Erroris the most common code indicating a problem with the server.