Telnet is just an interactive way to open a TCP connection to a listening socket. Since the telnet client blindly sends what you enter into this socket, it can theoretically emulate any other protocol over TCP. In fact, the fact that non-printable characters are interpreted by the keyboard driver is the only limit.
HTTP does not use non-printable characters except to distinguish between an HTTP header and a body with two consecutive "line breaks" (i.e., an "empty line").
Please note: I am not talking about the HTML tag tag here, but a payload (e.g. SOAP body).
No magic here basically.
Let's look at the dynamics of things.
HTTP supports several commands, such as GET, POST, PUT, etc ... Each command has its own syntax, and there is a related response with a consistent syntax and well-defined error codes. When you connect to an HTTP server using telnet, you open a socket connection and the server creates a stream to control the dialog box with your client. You can then simulate the browser by typing the command that the browser sends. Each time you press the CR key, the client sends a string to the server. If the command contains several lines, you can enter several lines, each of which corresponds to the command header line. After you press two CRs in a row (i.e., an empty line), the command header will be considered completed by the server, and the response will be collected together and sent back to your client. Since the goal of the telnet clientโs life is to receive the received characters (unless otherwise indicated), you can see the header and body of the response in the terminal window. Telnet stops. The browser will display HTML (if the response is an HTML page).
I hope this clarifies everything.
Alain pannetier
source share