ELinks 0.18.0
http_post Struct Reference

State of reading POST data from connection.uri->post and related files. More...

#include <post.h>

Collaboration diagram for http_post:

Data Fields

off_t total_upload_length
 Total size of the POST body to be uploaded.
off_t uploaded
 Amount of POST body data uploaded so far.
const char * post_data
 Points to the next byte to be read from connection.uri->post.
int post_fd
 File descriptor from which data is being read, or -1 if none.
size_t file_index
 Current position in the files array.
size_t file_count
 Number of files to be uploaded, i.e.
off_t file_read
 Number of bytes read from the current file so far.
struct http_post_filefiles
 Array of information about files to be uploaded.

(Note that these are not member symbols.)

void init_http_post (struct http_post *http_post)
 Initialize *http_post so that done_http_post() can be safely called.
void done_http_post (struct http_post *http_post)
 Free all resources owned by *http_post, but do not free the structure itself.
int open_http_post (struct http_post *http_post, const char *post_data, struct connection_state *error)
 Prepare to read POST data from a URI and possibly to upload files.
static int read_http_post_inline (struct http_post *http_post, char buffer[], int max, struct connection_state *error)
static int read_http_post_fd (struct http_post *http_post, char buffer[], int max, struct connection_state *error)
int read_http_post (struct http_post *http_post, char buffer[], int max, struct connection_state *error)
 Read data from connection.uri->post or from the files to which it refers.

Detailed Description

State of reading POST data from connection.uri->post and related files.

◆ done_http_post()

void done_http_post ( struct http_post * http_post)
related

Free all resources owned by *http_post, but do not free the structure itself.

It is safe to call this multiple times.

◆ init_http_post()

void init_http_post ( struct http_post * http_post)
related

Initialize *http_post so that done_http_post() can be safely called.

◆ open_http_post()

int open_http_post ( struct http_post * http_post,
const char * post_data,
struct connection_state * error )
related

Prepare to read POST data from a URI and possibly to upload files.

Parameters
http_postMust have been initialized with init_http_post().
[in]post_dataThe body of the POST request as formatted by get_form_uri(). However, unlike uri.post, post_data must not contain any Content-Type. The caller must ensure that the post_data pointer remains valid until done_http_post().
[out]errorIf the function fails, it writes the error state here so that the caller can pass that on to abort_connection(). If the function succeeds, the value of *error is undefined.

This function does not parse the Content-Type from uri.post; the caller must do that. This is because in local CGI, the child process handles the Content-Type (saving it to an environment variable before exec) but the parent process handles the body of the request (feeding it to the child process via a pipe).

Returns
nonzero on success, zero on error.

◆ read_http_post()

int read_http_post ( struct http_post * http_post,
char buffer[],
int max,
struct connection_state * error )
related

Read data from connection.uri->post or from the files to which it refers.

Returns
>0 if read that many bytes; 0 if EOF; -1 on error and set *error.

◆ read_http_post_fd()

int read_http_post_fd ( struct http_post * http_post,
char buffer[],
int max,
struct connection_state * error )
related
Returns
-2 if no data was read but the caller should retry; -1 if an error occurred and *error was set; 0 at end of data; a positive number if that many bytes were read.

◆ read_http_post_inline()

int read_http_post_inline ( struct http_post * http_post,
char buffer[],
int max,
struct connection_state * error )
related
Returns
-2 if no data was read but the caller should retry; -1 if an error occurred and *error was set; 0 at end of data; a positive number if that many bytes were read.

Field Documentation

◆ file_count

size_t http_post::file_count

Number of files to be uploaded, i.e.

the number of elements in the files array.

◆ file_index

size_t http_post::file_index

Current position in the files array.

This is the file that is currently being read (when post_fd != -1) or would be read next (when post_fd == -1).

◆ file_read

off_t http_post::file_read

Number of bytes read from the current file so far.

The value makes sense only when post_fd != -1.

◆ files

struct http_post_file* http_post::files

Array of information about files to be uploaded.

◆ post_data

const char* http_post::post_data

Points to the next byte to be read from connection.uri->post.

◆ post_fd

int http_post::post_fd

File descriptor from which data is being read, or -1 if none.

◆ total_upload_length

off_t http_post::total_upload_length

Total size of the POST body to be uploaded.

◆ uploaded

off_t http_post::uploaded

Amount of POST body data uploaded so far.

read_http_post() increments this.


The documentation for this struct was generated from the following files: