Pharos 0.7.23
Modern Web Framework & Web App Hosting Service.
Loading...
Searching...
No Matches
native_http_log.h
Go to the documentation of this file.
1/**
2 * @file
3 * @brief Declares HTTP logging and response formatting helpers.
4 */
5
6#ifndef PHAROS_NATIVE_HTTP_LOG_H
7#define PHAROS_NATIVE_HTTP_LOG_H
8
9/** @name HTTP logging helpers
10 * @{
11 */
12/**
13 * @brief Resolves the MIME type that should be used for a file path.
14 * @param path File path whose extension should be inspected.
15 * @return Newly allocated MIME type string, or NULL on failure.
16 */
17char *mime_type_for_path(const char *path);
18/**
19 * @brief Compacts free-form text into a single-line log-safe representation.
20 * @param value Source text to compact.
21 * @return Newly allocated compacted text, or NULL on failure.
22 */
23char *compact_log_text_native(const char *value);
24/**
25 * @brief Extracts the best client IP address from request headers.
26 * @param headers Normalized request headers.
27 * @return Newly allocated client IP string, or NULL when no address can be derived.
28 */
29char *request_real_ip_native(const char *headers);
30/**
31 * @brief Returns request headers with an explicit client IP header applied.
32 * @param headers Original normalized request headers.
33 * @param client_ip Client IP value to ensure is represented.
34 * @return Newly allocated header block, or NULL on failure.
35 */
36char *request_headers_with_client_ip_native(const char *headers, const char *client_ip);
37/**
38 * @brief Returns the canonical reason phrase for one HTTP status code.
39 * @param status_code HTTP status code to translate.
40 * @return Pointer to a static reason phrase string.
41 */
42const char *http_status_text_native(int status_code);
43/**
44 * @brief Extracts the HTTP status line from a raw HTTP response payload.
45 * @param response Raw HTTP response text.
46 * @return Newly allocated status line string, or NULL when it cannot be parsed.
47 */
48char *http_status_line_from_response_native(const char *response);
49/**
50 * @brief Extracts the numeric HTTP status code from a raw HTTP response payload.
51 * @param response Raw HTTP response text.
52 * @return Parsed status code, or 0 when it cannot be determined.
53 */
54int http_status_code_from_response_native(const char *response);
55
56
57/** @} */
58#endif
char * compact_log_text_native(const char *value)
Compacts free-form text into a single-line log-safe representation.
char * request_real_ip_native(const char *headers)
Extracts the best client IP address from request headers.
char * request_headers_with_client_ip_native(const char *headers, const char *client_ip)
Returns request headers with an explicit client IP header applied.
char * http_status_line_from_response_native(const char *response)
Extracts the HTTP status line from a raw HTTP response payload.
char * mime_type_for_path(const char *path)
Resolves the MIME type that should be used for a file path.
const char * http_status_text_native(int status_code)
Returns the canonical reason phrase for one HTTP status code.
int http_status_code_from_response_native(const char *response)
Extracts the numeric HTTP status code from a raw HTTP response payload.