Pharos 0.7.23
Modern Web Framework & Web App Hosting Service.
Loading...
Searching...
No Matches
native_http_log.h File Reference

Declares HTTP logging and response formatting helpers. More...

Go to the source code of this file.

Functions

HTTP logging helpers
char * mime_type_for_path (const char *path)
 Resolves the MIME type that should be used for a file path.
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.
const char * http_status_text_native (int status_code)
 Returns the canonical reason phrase for one HTTP status code.
char * http_status_line_from_response_native (const char *response)
 Extracts the HTTP status line from a raw HTTP response payload.
int http_status_code_from_response_native (const char *response)
 Extracts the numeric HTTP status code from a raw HTTP response payload.

Detailed Description

Declares HTTP logging and response formatting helpers.

Definition in file native_http_log.h.

Function Documentation

◆ compact_log_text_native()

char * compact_log_text_native ( const char * value)

Compacts free-form text into a single-line log-safe representation.

Parameters
valueSource text to compact.
Returns
Newly allocated compacted text, or NULL on failure.

Definition at line 40 of file native_http_log.c.

References buffer_append(), buffer_free(), buffer_init(), Buffer::data, Buffer::len, and pharos_http_log_strdup.

Referenced by native_write_access_log(), and native_write_error_log().

◆ http_status_code_from_response_native()

int http_status_code_from_response_native ( const char * response)

Extracts the numeric HTTP status code from a raw HTTP response payload.

Parameters
responseRaw HTTP response text.
Returns
Parsed status code, or 0 when it cannot be determined.

Definition at line 242 of file native_http_log.c.

Referenced by handle_app_or_runtime_request().

◆ http_status_line_from_response_native()

char * http_status_line_from_response_native ( const char * response)

Extracts the HTTP status line from a raw HTTP response payload.

Parameters
responseRaw HTTP response text.
Returns
Newly allocated status line string, or NULL when it cannot be parsed.

Definition at line 221 of file native_http_log.c.

References dup_range(), and pharos_http_log_strdup.

Referenced by handle_app_or_runtime_request().

◆ http_status_text_native()

const char * http_status_text_native ( int status_code)

Returns the canonical reason phrase for one HTTP status code.

Parameters
status_codeHTTP status code to translate.
Returns
Pointer to a static reason phrase string.

Definition at line 209 of file native_http_log.c.

Referenced by native_serve_static_file(), and native_write_access_log().

◆ mime_type_for_path()

char * mime_type_for_path ( const char * path)

Resolves the MIME type that should be used for a file path.

Parameters
pathFile path whose extension should be inspected.
Returns
Newly allocated MIME type string, or NULL on failure.

Definition at line 25 of file native_http_log.c.

References pharos_http_log_strdup.

Referenced by native_dynamic_media_serve_asset(), and native_serve_static_file().

◆ request_headers_with_client_ip_native()

char * request_headers_with_client_ip_native ( const char * headers,
const char * client_ip )

Returns request headers with an explicit client IP header applied.

Parameters
headersOriginal normalized request headers.
client_ipClient IP value to ensure is represented.
Returns
Newly allocated header block, or NULL on failure.

Definition at line 147 of file native_http_log.c.

References buffer_append(), buffer_free(), buffer_init(), Buffer::data, pharos_http_log_strcasecmp, pharos_http_log_strdup, and trim_in_place().

Referenced by native_write_access_log(), and native_write_error_log().

◆ request_real_ip_native()

char * request_real_ip_native ( const char * headers)

Extracts the best client IP address from request headers.

Parameters
headersNormalized request headers.
Returns
Newly allocated client IP string, or NULL when no address can be derived.

Definition at line 75 of file native_http_log.c.

References pharos_http_log_strcasecmp, pharos_http_log_strdup, and trim_in_place().

Referenced by native_write_access_log(), native_write_error_log(), and write_error_report_native().