.Dd December 15, 2024 .Dt LIBHTTPC_LOADREQUEST 3 .Os . .Sh NAME .Nm LibHTTPC_loadRequest , .Nm LibHTTPC_readRequest .Nd parse HTTP request . .Sh SYNOPSIS .In libhttpc/libhttpc.h .Ft "struct LibHTTPC_Request *" .Fo LibHTTPC_loadRequest .Fa "struct LibHTTPC_Request *request_buf" .Fa "char *buf" .Fc .Ft "struct LibHTTPC_Request *" .Fo LibHTTPC_readRequest .Fa "int sockfd" .Fa "struct LibHTTPC_Request *request_buf" .Fa "char *buf" .Fa "size_t buf_len" .Fc . .Sh DESCRIPTION .Fn LibHTTPC_loadRequest parses .Fa buf and fills .Fa request_buf . . .Pp .Fn LibHTTPC_readRequest parses .Xr libhttpc_request 3 from .Xr socket 2 directly. .Fa buf can't be NULL. Behavior for this should be implemented later, though. . .Pp If .Fa request_buf is .Dv NULL , then function will allocate buffer itself. . .Sh RETURN VALUES .Fn LibHTTPC_loadRequest returns pointer to .Fa request_buf on success, or .Dv NULL on error. . .Pp If .Fn LibHTTPC_loadRequest returned .Dv NULL , it could mean either: .Bl -bullet .It If .Xr errno 3 is 0 (Success), it means that user hadn't set .Xr libhttpc-alloc 3 . .It If .Xr errno 3 is not 0, it means that some allocation function has failed. Read .Ql ERRORS section of .Xr malloc 3 for more information. .El . .Pp If .Fn LibHTTPC_readRequest returned .Dv NULL , it could mean either: .Bl -bullet .It If .Xr errno 3 is 0 (Success), then either: .Bl -bullet .It Either .Fa buf is .Dv NULL or .Fa buf_len is 0 .It Read text about return values of .Fn LibHTTPC_loadRequest .El .It If .Xr errno 3 is not 0, it means that either: .Bl -bullet .It .Xr recv 2 has failed. Read .Ql ERRORS section of .Xr recv 2 for more information. .It Read text about return values of .Fn LibHTTPC_loadRequest .El .El . .Sh SEE ALSO .Xr libhttpc 3 , .Xr libhttpc-alloc 3 , .Xr libhttpc_header 3 , .Xr libhttpc_request 3 . .Sh AUTHORS .An Nakidai Perumenei Aq Mt nakidai@disroot.org . .Sh CAVEATS .Fn LibHTTPC_loadRequest function will destroy the buffer while working. It sets 0 char on the end of every string in .Fa request_buf . Note that .Fn LibHTTPC_readRequest uses .Fn LibHTTPC_loadRequest under the hood.