http_output.h

来自「AMLOGIC DPF source code」· C头文件 代码 · 共 190 行

H
190
字号
/*******************************************************************
 * 
 *  Copyright C 2005 by Amlogic, Inc. All Rights Reserved.
 *
 *  Description: 
 *
 *  Author: Eric Knudstrup
 *  Created: Mon Jun 27 13:16:01 2005
 *
 *******************************************************************/

#ifndef HTTP_OUTPUT_H
#define HTTP_OUTPUT_H

/** 
 * @file http_output.h
 * HTTP message output functions.
 */

/**
 * @defgroup http_output HTTP message output functions.
 * @ingroup Network
 */


/*@{*/
/**
 * Register output data handlers for an outgoing HTTP message.
 * @param[in] message Message to which these handlers apply.
 * @param[in] out_data_cb Callback to retrieve next block of data.
 * @param[in] out_ctxt User data context for out_data_cb.
 */
extern void
http_register_data_handler(HTTPOutputMessage_t *message, 
                           HTTPOutputCb_t out_data_cb,
                           void *out_ctxt);

/**
 * Free all memory associated with \a message.
 */
extern void
http_output_destroy(HTTPOutputMessage_t *message);

/**
 * Reset the cursor of request to 0.
 * @param [in] request HTTPOutputMessage_t to operate on.
 */
extern void
http_output_reset_cursor(HTTPOutputMessage_t *request);

/**
 * Return the current payload pointer for the request's
 * cursor.
 * @param [in] request 
 * @param [out] buffer A pointer to the next block of data on success.
 * @param [in,out] len On input, this is the amount of bytes
 *                  that the TCP control block can take.
 *                  Output, the number of bytes available if less.
 *
 * @returns HTTP_OUT_OK More data is available.
 *          HTTP_OUT_COMPLETE At end of data.
 *          HTTP_OUT_ERROR The message may be invalid or a resource
 *                         error occured.
 *          HTTP_OUT_ASYNC Need to pause to wait for more data.
 */
extern HTTPOutputCbResult_t
http_output_get_cursor(HTTPOutputMessage_t *request, 
                       char **buffer, int *len);


/**
 * Consume count bytes from the request.
 */
extern void
http_output_consume(HTTPOutputMessage_t *request, int count);

/**
 * Finish setting up this request in preparation for sending
 * it to the remote end.
 */
extern err_t 
http_output_complete(HTTPOutputMessage_t *request, HTTPOutHeaderList_t *headers);

/**
 * Append data onto an HTTP request
 *
 * @param [in] request The request
 * @param [in] data The data
 * @param [in] len Length of the data
 * @param [in] copy If this parameter is FALSE, the data
 * is expected to be a static memory region.
 * If it is TRUE, the data will be copied.
 *
 * @returns ERR_OK on success, ERR_MEM on failure.
 */
extern err_t
http_output_append(HTTPOutputMessage_t *request, 
 char *data, int len, 
 int copy);

/**
 * Append data onto an HTTP request
 *
 * @param [in] request The request.
 * @param [in] p A pbuf to append.
 *
 * @returns ERR_OK.
 */
extern err_t
http_output_append_pbuf(HTTPOutputMessage_t *request, 
 struct pbuf *p);

/**
 * Append static headers onto the request.
 *
 * @returns ERR_OK on success.
 */
extern err_t
http_output_append_static(HTTPOutputMessage_t *request, HTTPOutHeaderList_t *headers);

/**
 * Release all memory for a list of static \a headers.
 */
extern void
http_destroy_static_headers(HTTPOutHeaderList_t *headers);

/** 
 * Remove a static header field from this session
 *
 * @returns TRUE if the field was found, FALSE if not
 * @ingroup http_client
 */
extern int
http_remove_static_header(HTTPOutHeaderList_t *headers, char *field);

/**
 * Duplicate a set of static headers.
 * @param[out] out List to copy to.
 * @param[in] in List to copy from.
 *
 * @returns 0 if succeeded, nonzero otherwise.
 */
extern int
http_duplicate_headers(HTTPOutHeaderList_t *out, HTTPOutHeaderList_t *in);

/** 
 * Add a static header field to be appended to each request/response.
 * Each field can only be added once.
 *
 * Example:
 * http_add_static_header(client, "Host", "www.test.com");
 *
 * @returns TRUE if the field was inserted, FALSE if not
 * @ingroup http_client
 */
extern int
http_add_static_header(HTTPOutHeaderList_t *headers, char *field, char *value);

/**
 * Create a new HTTP request message.
 * @param [in] proto Protocol to use ("HTTP" or "RTSP" or "SIP").
 * @param [in] major Major protocol number to use.
 * @param [in] minor Minor protocol number to use.
 * @param [in] method Request method ("GET").
 * @param [in] uri URI to send ("http://www.blah.com").
 * 
 * @returns A new HTTPOutputMessage_t pointer if successful, NULL if not.
 */
extern HTTPOutputMessage_t *
http_request_create(const char *proto, char major, char minor, char *method, char *uri);

/**
 * Create a new HTTP response message.
 * @param [in] proto Protocol to use ("HTTP" or "RTSP" or "SIP").
 * @param [in] major Major protocol number to use.
 * @param [in] minor Minor protocol number to use.
 * @param [in] status_code HTTP status code for this response.
 * @param [in] status_message HTTP Status message string.
 * 
 * @returns A new HTTPOutputMessage_t pointer if successful, NULL if not.
 */
extern HTTPOutputMessage_t *
http_response_create(const char *proto, char major, char minor, int status_code, char *status_message);


/*;end emacs generated header for file http_output.c. Global function declarations only. */

#endif
/*@}*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?