MHEG5  18.9.0
MHEG5 Documentation
Classes | Macros | Typedefs | Functions
curlInterface.c File Reference

Manages the interface between HTTP component and curl library. More...

#include "http_platform.h"
#include <assert.h>
#include <string.h>
#include <curl/curl.h>
#include <openssl/ssl.h>
#include "dvb_misc.h"
#include "stb_memory.h"
#include "stb_os.h"
#include "glue_debug.h"

Go to the source code of this file.

Classes

struct  AllocInfo_t
 
struct  HttpClientInfo_tag
 
struct  HttpCertList_tag
 

Macros

#define HTTP_IDLE_TIMEOUT   200 /* ms */
 
#define MAX_USER_AGENT   256
 
#define CHK_EASY(call)
 
#define DBG_ENTRY(x)
 
#define DBG_EXIT(x)
 

Typedefs

typedef struct HttpClientInfo_tagHttpClientInfo_t
 
typedef struct HttpCertList_tagHttpCertList_t
 

Functions

E_HttpErr HP_Initialise (void)
 Initialise the HTTP interface. More...
 
E_HttpErr HP_SetUserAgent (U8BIT *user_agent)
 Set user agent for HTTP client. More...
 
E_HttpErr HP_SetTimeout (U16BIT timeout)
 Set timeout (in seconds) for HTTP requests. The timeout applies to connections (i.e. the time it takes to connect to the server) as well as response time (i.e the time it takes to download the content). Between sending the request and receiving the first byte of the the response there is no timeout. More...
 
E_HttpErr HP_CreateRequest (U8BIT *url, E_HttpRequestType type, void **handle)
 Create an HTTP request. The URL is provided, and is guaranteed to be either "http://..." or "https://..." The request type is also provided. Streaming request is the same as a GET request, except that a "Range:" header is also allowed for it. More...
 
E_HttpErr HP_StartRequest (void *handle)
 Start an HTTP request. More...
 
E_HttpErr HP_ResumeRequest (void *handle)
 Resume an HTTP request. More...
 
E_HttpErr HP_StopRequest (void *handle)
 Stop an HTTP request. More...
 
E_HttpErr HP_DestroyRequest (void *handle)
 Destroy an HTTP request. More...
 
E_HttpErr HP_SetUserData (void *handle, void *userdata)
 Set user data associated with an HTTP request. More...
 
E_HttpErr HP_AddHeader (void *handle, U8BIT *header)
 Add HTTP header to HTTP request. More...
 
E_HttpErr HP_SetPostData (void *handle, U8BIT *postdata)
 Set POST data for an HTTP request. More...
 
E_HttpErr HP_SetRange (void *handle, U8BIT *range)
 Set "Range:" header for an HTTP request. More...
 
E_HttpErr HP_GetRedirectUrl (void *handle, U8BIT **url)
 Get redirection URL for HTTP request. More...
 
E_HttpErr HP_AddTlsCertificate (U8BIT *cert, U32BIT len)
 Add a certificate for TLS connections. More...
 
E_HttpErr HP_ClearTlsCertificates (void)
 Clear TLS certificates. More...
 
E_HttpErr HP_WaitForAction (void)
 Wait until there is some activity on one (or more) of the HTTP requests, or until some other condition is met. The exact details depend on the HTTP client. More...
 
E_HttpErr HP_Process (U16BIT *active_count)
 Process HTTP requests. This may cause request callbacks to be called. More...
 
E_HttpErr HP_Terminate (void)
 Terminate the HTTP interface. More...
 

Detailed Description

Manages the interface between HTTP component and curl library.

Date
22/02/2010
Author
Omri Barel

Definition in file curlInterface.c.

Macro Definition Documentation

#define CHK_EASY (   call)
Value:
{ \
CURLcode code; \
code = (call); \
if (code != CURLE_OK) \
{ \
TRACE(TERROR, ("FAIL %s",#call)) \
return FALSE; \
} \
}
#define FALSE
Definition: techtype.h:68
#define TRACE(t, x)
Definition: glue_debug.h:118

Definition at line 45 of file curlInterface.c.

#define DBG_ENTRY (   x)

Definition at line 61 of file curlInterface.c.

#define DBG_EXIT (   x)

Definition at line 62 of file curlInterface.c.

#define HTTP_IDLE_TIMEOUT   200 /* ms */

Definition at line 42 of file curlInterface.c.

#define MAX_USER_AGENT   256

Definition at line 43 of file curlInterface.c.

Typedef Documentation

typedef struct HttpCertList_tag * HttpCertList_t

Function Documentation

E_HttpErr HP_AddHeader ( void *  handle,
U8BIT header 
)

Add HTTP header to HTTP request.

Parameters
handleThe handle of the request
headerHeader to add (null-terminated string)
Returns
HTTP_OK if the function was successful HTTP_ERR_INTERNAL if an internal error was encountered HTTP_ERR_BAD_PARAMETER if the function received bad parameters

Definition at line 499 of file curlInterface.c.

E_HttpErr HP_AddTlsCertificate ( U8BIT cert,
U32BIT  len 
)

Add a certificate for TLS connections.

Parameters
certCertificate data (X.509 DER format)
lenCertificate length
Returns
HTTP_OK if the function was successful HTTP_ERR_INTERNAL if an internal error was encountered HTTP_ERR_BAD_PARAMETER if the function received bad parameters

Definition at line 642 of file curlInterface.c.

E_HttpErr HP_ClearTlsCertificates ( void  )

Clear TLS certificates.

Returns
HTTP_OK if the function was successful HTTP_ERR_INTERNAL if an internal error was encountered

Definition at line 694 of file curlInterface.c.

E_HttpErr HP_CreateRequest ( U8BIT url,
E_HttpRequestType  type,
void **  handle 
)

Create an HTTP request. The URL is provided, and is guaranteed to be either "http://..." or "https://..." The request type is also provided. Streaming request is the same as a GET request, except that a "Range:" header is also allowed for it.

Parameters
urlURL for request
typeRequest type
handleNew request handle, or NULL if it cannot be created
Returns
HTTP_OK if the function was successful HTTP_ERR_INTERNAL if an internal error was encountered HTTP_ERR_BAD_PARAMETER if the function received bad parameters

Definition at line 187 of file curlInterface.c.

E_HttpErr HP_DestroyRequest ( void *  handle)

Destroy an HTTP request.

Parameters
handleThe handle of the request to destroy
Returns
HTTP_OK if the function was successful HTTP_ERR_INTERNAL if an internal error was encountered HTTP_ERR_BAD_PARAMETER if the function received bad parameters

Definition at line 420 of file curlInterface.c.

E_HttpErr HP_GetRedirectUrl ( void *  handle,
U8BIT **  url 
)

Get redirection URL for HTTP request.

Parameters
handleThe handle of the HTTP request
urlRedirection URL
Returns
HTTP_OK if the function was successful HTTP_ERR_INTERNAL if an internal error was encountered HTTP_ERR_BAD_PARAMETER if the function received bad parameters

Definition at line 605 of file curlInterface.c.

E_HttpErr HP_Initialise ( void  )

Initialise the HTTP interface.

Returns
HTTP_OK if the interface is initialised HTTP_ERR_INTERNAL if the interface cannot be initialised

Definition at line 111 of file curlInterface.c.

E_HttpErr HP_Process ( U16BIT active_count)

Process HTTP requests. This may cause request callbacks to be called.

Parameters
active_countNumber of active requests
Returns
HTTP_OK if the function was successful HTTP_ERR_INTERNAL if an internal error was encountered HTTP_ERR_BAD_PARAMETER if the function received bad parameters

Definition at line 769 of file curlInterface.c.

E_HttpErr HP_ResumeRequest ( void *  handle)

Resume an HTTP request.

Parameters
handleThe handle of the request to resume
Returns
HTTP_OK if the function was successful HTTP_ERR_INTERNAL if an internal error was encountered HTTP_ERR_BAD_PARAMETER if the function received bad parameters

Definition at line 345 of file curlInterface.c.

E_HttpErr HP_SetPostData ( void *  handle,
U8BIT postdata 
)

Set POST data for an HTTP request.

Parameters
handleThe handle of the request
postdataNull-terminated string containing the POST data
Returns
HTTP_OK if the function was successful HTTP_ERR_INTERNAL if an internal error was encountered HTTP_ERR_BAD_PARAMETER if the function received bad parameters

Definition at line 535 of file curlInterface.c.

E_HttpErr HP_SetRange ( void *  handle,
U8BIT range 
)

Set "Range:" header for an HTTP request.

Parameters
handleThe handle of the request
rangeNull-terminated string containing the range details
Returns
HTTP_OK if the function was successful HTTP_ERR_INTERNAL if an internal error was encountered HTTP_ERR_BAD_PARAMETER if the function received bad parameters

Definition at line 574 of file curlInterface.c.

E_HttpErr HP_SetTimeout ( U16BIT  timeout)

Set timeout (in seconds) for HTTP requests. The timeout applies to connections (i.e. the time it takes to connect to the server) as well as response time (i.e the time it takes to download the content). Between sending the request and receiving the first byte of the the response there is no timeout.

Parameters
timeoutRequest timeout in seconds
Returns
HTTP_OK if the function was successful HTTP_ERR_INTERNAL if an internal error was encountered HTTP_ERR_BAD_PARAMETER if the function received bad parameters

Definition at line 163 of file curlInterface.c.

E_HttpErr HP_SetUserAgent ( U8BIT user_agent)

Set user agent for HTTP client.

Parameters
user_agentUser agent string
Returns
HTTP_OK if the interface is initialised HTTP_ERR_INTERNAL if the interface cannot be initialised

Definition at line 140 of file curlInterface.c.

E_HttpErr HP_SetUserData ( void *  handle,
void *  userdata 
)

Set user data associated with an HTTP request.

Parameters
handleThe handle of the request
userdataUser data to be associated with the request
Returns
HTTP_OK if the function was successful HTTP_ERR_INTERNAL if an internal error was encountered HTTP_ERR_BAD_PARAMETER if the function received bad parameters

Definition at line 464 of file curlInterface.c.

E_HttpErr HP_StartRequest ( void *  handle)

Start an HTTP request.

Parameters
handleThe handle of the request to start
Returns
HTTP_OK if the function was successful HTTP_ERR_INTERNAL if an internal error was encountered HTTP_ERR_BAD_PARAMETER if the function received bad parameters

Definition at line 285 of file curlInterface.c.

E_HttpErr HP_StopRequest ( void *  handle)

Stop an HTTP request.

Parameters
handleThe handle of the request to stop
Returns
HTTP_OK if the function was successful HTTP_ERR_INTERNAL if an internal error was encountered HTTP_ERR_BAD_PARAMETER if the function received bad parameters

Definition at line 386 of file curlInterface.c.

E_HttpErr HP_Terminate ( void  )

Terminate the HTTP interface.

Returns
HTTP_OK if the interface is terminated HTTP_ERR_INTERNAL if the interface cannot be terminated

Definition at line 856 of file curlInterface.c.

E_HttpErr HP_WaitForAction ( void  )

Wait until there is some activity on one (or more) of the HTTP requests, or until some other condition is met. The exact details depend on the HTTP client.

Returns
HTTP_OK if the function was successful HTTP_ERR_INTERNAL if an internal error was encountered HTTP_ERR_BAD_PARAMETER if the function received bad parameters

Definition at line 724 of file curlInterface.c.