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

Pharos-owned multipart form-data parsing for in-process dynamic handling. More...

#include <stddef.h>

Go to the source code of this file.

Functions

Boundary extraction
char * native_dynamic_multipart_boundary (const char *content_type)
 Extracts the MIME boundary string from a Content-Type header.
Part lookup
int native_dynamic_multipart_find_part (const unsigned char *body, size_t body_len, const char *content_type, const char *field_name, char **out_text, char **out_filename, const unsigned char **out_content_start, size_t *out_content_len)
 Finds a named part in a multipart request body.
Filename extraction
char * native_dynamic_multipart_filename (const unsigned char *body, size_t body_len, const char *content_type, const char *field_name)
 Extracts the uploaded filename for a named multipart file part.
Text extraction
char * native_dynamic_multipart_extract_text (const unsigned char *body, size_t body_len, const char *content_type, const char *field_name)
 Extracts a text value from a multipart form field.
File extraction
int native_dynamic_multipart_extract_file (const unsigned char *body, size_t body_len, const char *content_type, const char *field_name, const char *output_path)
 Extracts file content from a multipart file part and writes it to disk.

Detailed Description

Pharos-owned multipart form-data parsing for in-process dynamic handling.

Provides boundary extraction, part lookup, filename extraction, and file-part extraction so that the dynamic runtime can process multipart uploads without delegating to a child process or relying on app-owned shell logic.

Definition in file native_dynamic_multipart.h.

Function Documentation

◆ native_dynamic_multipart_boundary()

char * native_dynamic_multipart_boundary ( const char * content_type)

Extracts the MIME boundary string from a Content-Type header.

Extracts the MIME boundary from a Content-Type header value.

Parameters
content_typeThe full Content-Type header value.
Returns
Newly allocated boundary string (without the leading -- ), or NULL when the boundary cannot be determined. Caller must free.

Extracts the MIME boundary string from a Content-Type header.

Handles both quoted and unquoted boundary parameters.

Parameters
content_typeThe full Content-Type header value.
Returns
Newly allocated boundary string (without the leading -- ), or NULL when the boundary cannot be determined.

Definition at line 82 of file native_dynamic_multipart.c.

References multipart_dup_range().

Referenced by native_dynamic_multipart_find_part().

◆ native_dynamic_multipart_extract_file()

int native_dynamic_multipart_extract_file ( const unsigned char * body,
size_t body_len,
const char * content_type,
const char * field_name,
const char * output_path )

Extracts file content from a multipart file part and writes it to disk.

Parameters
bodyRaw multipart body bytes.
body_lenByte length of body.
content_typeThe full Content-Type header.
field_nameThe form field name of the file input.
output_pathDestination file path on disk.
Returns
0 on success, non-zero on failure.

Definition at line 306 of file native_dynamic_multipart.c.

References native_dynamic_multipart_find_part().

Referenced by handle_dynamic_multipart_extract_file_command().

◆ native_dynamic_multipart_extract_text()

char * native_dynamic_multipart_extract_text ( const unsigned char * body,
size_t body_len,
const char * content_type,
const char * field_name )

Extracts a text value from a multipart form field.

Parameters
bodyRaw multipart body bytes.
body_lenByte length of body.
content_typeThe full Content-Type header.
field_nameThe form field name to extract.
Returns
Newly allocated text value, or NULL when not found. Caller must free.

Definition at line 295 of file native_dynamic_multipart.c.

References native_dynamic_multipart_find_part().

Referenced by handle_dynamic_multipart_extract_text_command(), request_form_value_dup_logic_local(), and request_form_value_dup_runtime().

◆ native_dynamic_multipart_filename()

char * native_dynamic_multipart_filename ( const unsigned char * body,
size_t body_len,
const char * content_type,
const char * field_name )

Extracts the uploaded filename for a named multipart file part.

Parameters
bodyRaw multipart body bytes.
body_lenByte length of body.
content_typeThe full Content-Type header.
field_nameThe form field name of the file input.
Returns
Newly allocated filename string, or NULL when not found. Caller must free.

Definition at line 284 of file native_dynamic_multipart.c.

References native_dynamic_multipart_find_part().

Referenced by handle_dynamic_multipart_filename_command().

◆ native_dynamic_multipart_find_part()

int native_dynamic_multipart_find_part ( const unsigned char * body,
size_t body_len,
const char * content_type,
const char * field_name,
char ** out_text,
char ** out_filename,
const unsigned char ** out_content_start,
size_t * out_content_len )

Finds a named part in a multipart request body.

Searches body for a part whose Content-Disposition name matches field_name. When found, optionally returns the text content, the uploaded filename, and/or the raw content range within body.

Parameters
bodyRaw multipart body bytes.
body_lenByte length of body.
content_typeThe full Content-Type header (must contain the boundary).
field_nameThe form field name to locate.
out_textReceives a NUL-terminated copy of the part content (may be NULL to skip).
out_filenameReceives the uploaded filename (may be NULL to skip).
out_content_startReceives a pointer into body at the content start (may be NULL to skip).
out_content_lenReceives the content byte length (may be NULL to skip).
Returns
1 when a matching part was found, 0 otherwise.

Definition at line 140 of file native_dynamic_multipart.c.

References multipart_dup_range(), multipart_header_param_dup(), multipart_memmem(), and native_dynamic_multipart_boundary().

Referenced by native_dynamic_multipart_extract_file(), native_dynamic_multipart_extract_text(), native_dynamic_multipart_filename(), and store_uploaded_media().