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

Parses HTTP requests from native connections into method, target, header, cookie, and body fields. More...

#include "native_http_request.h"
#include "native_spawn_temp_body.h"
#include "native_support.h"
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <strings.h>
#include <sys/socket.h>

Go to the source code of this file.

Macros

#define PHAROS_HTTP_MAX_HEADER_BYTES   (16U * 1024U)
#define PHAROS_HTTP_MAX_REQUEST_LINE_BYTES   (8U * 1024U)
#define PHAROS_HTTP_MAX_HEADER_LINE_BYTES   (4U * 1024U)
#define PHAROS_HTTP_MAX_HEADER_COUNT   100U
#define PHAROS_HTTP_MAX_BODY_BYTES   (1U * 1024U * 1024U)
#define PHAROS_HTTP_MAX_MULTIPART_BODY_BYTES   (16U * 1024U * 1024U)
#define native_http_request_strdup   strdup

Functions

void free_http_request_native (HttpRequest *request)
 Releases heap-owned fields in a parsed HTTP request record.
static int parse_content_length_header_native (const char *header_value, long *content_length)
static size_t native_http_body_limit (int is_multipart)
static int contains_chunked_transfer_native (const char *header_value)
static int native_write_temp_body_chunk (int temp_fd, const char *data, size_t data_len)
static int native_spool_request_body_to_temp_file (Buffer *buffer, size_t body_offset, long content_length, NativeConnection *connection, char **body_file_path_out)
static void apply_known_header_native (HttpRequest *request, const char *header_name, const char *header_value, long *content_length, int *chunked_transfer)
int parse_http_request_native (NativeConnection *connection, HttpRequest *request)
 Parses an HTTP request from a native connection into a request record.

Detailed Description

Parses HTTP requests from native connections into method, target, header, cookie, and body fields.

Definition in file native_http_request.c.

Macro Definition Documentation

◆ native_http_request_strdup

#define native_http_request_strdup   strdup

◆ PHAROS_HTTP_MAX_BODY_BYTES

#define PHAROS_HTTP_MAX_BODY_BYTES   (1U * 1024U * 1024U)

Definition at line 21 of file native_http_request.c.

Referenced by native_http_body_limit().

◆ PHAROS_HTTP_MAX_HEADER_BYTES

#define PHAROS_HTTP_MAX_HEADER_BYTES   (16U * 1024U)

Definition at line 17 of file native_http_request.c.

Referenced by parse_http_request_native().

◆ PHAROS_HTTP_MAX_HEADER_COUNT

#define PHAROS_HTTP_MAX_HEADER_COUNT   100U

Definition at line 20 of file native_http_request.c.

Referenced by parse_http_request_native().

◆ PHAROS_HTTP_MAX_HEADER_LINE_BYTES

#define PHAROS_HTTP_MAX_HEADER_LINE_BYTES   (4U * 1024U)

Definition at line 19 of file native_http_request.c.

Referenced by parse_http_request_native().

◆ PHAROS_HTTP_MAX_MULTIPART_BODY_BYTES

#define PHAROS_HTTP_MAX_MULTIPART_BODY_BYTES   (16U * 1024U * 1024U)

Definition at line 22 of file native_http_request.c.

Referenced by native_http_body_limit().

◆ PHAROS_HTTP_MAX_REQUEST_LINE_BYTES

#define PHAROS_HTTP_MAX_REQUEST_LINE_BYTES   (8U * 1024U)

Definition at line 18 of file native_http_request.c.

Referenced by parse_http_request_native().

Function Documentation

◆ apply_known_header_native()

void apply_known_header_native ( HttpRequest * request,
const char * header_name,
const char * header_value,
long * content_length,
int * chunked_transfer )
static

◆ contains_chunked_transfer_native()

int contains_chunked_transfer_native ( const char * header_value)
static

Definition at line 71 of file native_http_request.c.

Referenced by apply_known_header_native().

◆ free_http_request_native()

void free_http_request_native ( HttpRequest * request)

◆ native_http_body_limit()

size_t native_http_body_limit ( int is_multipart)
static

◆ native_spool_request_body_to_temp_file()

int native_spool_request_body_to_temp_file ( Buffer * buffer,
size_t body_offset,
long content_length,
NativeConnection * connection,
char ** body_file_path_out )
static

◆ native_write_temp_body_chunk()

int native_write_temp_body_chunk ( int temp_fd,
const char * data,
size_t data_len )
static

Definition at line 91 of file native_http_request.c.

Referenced by native_spool_request_body_to_temp_file().

◆ parse_content_length_header_native()

int parse_content_length_header_native ( const char * header_value,
long * content_length )
static

Definition at line 47 of file native_http_request.c.

Referenced by apply_known_header_native().

◆ parse_http_request_native()