Github User Fetcher 1.0.0
C Application with Server and GUI
|
Manages a single HTTP session with a client. More...
Public Member Functions | |
HttpSession (tcp::socket socket) | |
Constructs an HttpSession with the given socket. | |
void | start () |
Starts processing the HTTP session. | |
Private Member Functions | |
void | read_request () |
Initiates asynchronous read of the HTTP request from the client. | |
void | handle_request () |
Processes the HTTP request and sends a corresponding response. | |
Private Attributes | |
tcp::socket | socket_ |
The socket used for communication with the client. | |
beast::flat_buffer | buffer_ |
Buffer for reading data from the socket. | |
http::request< http::string_body > | req_ |
HTTP request object. | |
Manages a single HTTP session with a client.
This class handles reading an HTTP request, processing it by fetching a GitHub user's data, and sending an appropriate HTTP response. Each client connection is handled in its own instance.
Definition at line 36 of file server.cpp.
|
inlineexplicit |
Constructs an HttpSession with the given socket.
socket | The TCP socket associated with the client connection. |
Definition at line 42 of file server.cpp.
|
inlineprivate |
Processes the HTTP request and sends a corresponding response.
If the request target contains a valid GitHub username, it fetches the user's data and returns it as JSON. Otherwise, it responds with an error message.
Definition at line 74 of file server.cpp.
References User::company, User::location, User::login, User::name, req_, and socket_.
|
inlineprivate |
Initiates asynchronous read of the HTTP request from the client.
Definition at line 57 of file server.cpp.
References buffer_, req_, and socket_.
Referenced by start().
|
inline |
Starts processing the HTTP session.
Definition at line 47 of file server.cpp.
References read_request().
|
private |
Buffer for reading data from the socket.
Definition at line 51 of file server.cpp.
Referenced by read_request().
|
private |
HTTP request object.
Definition at line 52 of file server.cpp.
Referenced by handle_request(), and read_request().
|
private |
The socket used for communication with the client.
Definition at line 50 of file server.cpp.
Referenced by handle_request(), and read_request().