UFO: Alien Invasion
Loading...
Searching...
No Matches
http.h File Reference
#include "common.h"
#include <curl/curl.h>
Include dependency graph for http.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  dlqueue_t
struct  dlhandle_t
struct  upparam_t

Macros

#define CURL_STATICLIB

Typedefs

typedef void(* http_callback_t) (const char *response, void *userdata)

Enumerations

enum  dlq_state { DLQ_STATE_NOT_STARTED , DLQ_STATE_RUNNING , DLQ_STATE_DONE }

Functions

bool HTTP_Encode (const char *url, char *out, size_t outLength)
 This function converts the given url to an URL encoded string. All input characters that are not a-z, A-Z, 0-9, '-', '.', '_' or '~' are converted to their "URL escaped" version (NN where NN is a two-digit hexadecimal number).
bool HTTP_GetToFile (const char *url, FILE *file, const char *postfields=nullptr)
 Downloads the given url into the given file.
bool HTTP_GetURL (const char *url, http_callback_t callback, void *userdata=nullptr, const char *postfields=nullptr)
 Downloads the given url and return the data to the callback (optional).
bool HTTP_PutFile (const char *formName, const char *fileName, const char *url, const upparam_t *params)
size_t HTTP_Recv (void *ptr, size_t size, size_t nmemb, void *stream)
 libcurl callback for HTTP_GetURL
size_t HTTP_Header (void *ptr, size_t size, size_t nmemb, void *stream)
 libcurl callback to update header info.
void HTTP_Cleanup (void)
 UFO is exiting or we're changing servers. Clean up.
bool HTTP_ExtractComponents (const char *url, char *scheme, size_t schemeLength, char *host, size_t hostLength, char *path, size_t pathLength, int *port)
 Extract the servername, the port and the path part of the given url.

Macro Definition Documentation

◆ CURL_STATICLIB

#define CURL_STATICLIB

Definition at line 30 of file http.h.

Typedef Documentation

◆ http_callback_t

typedef void(* http_callback_t) (const char *response, void *userdata)

Definition at line 65 of file http.h.

Enumeration Type Documentation

◆ dlq_state

enum dlq_state
Enumerator
DLQ_STATE_NOT_STARTED 
DLQ_STATE_RUNNING 
DLQ_STATE_DONE 

Definition at line 34 of file http.h.

Function Documentation

◆ HTTP_Cleanup()

void HTTP_Cleanup ( void )

UFO is exiting or we're changing servers. Clean up.

Definition at line 406 of file http.cpp.

Referenced by Qcommon_Shutdown().

◆ HTTP_Encode()

bool HTTP_Encode ( const char * url,
char * out,
size_t outLength )

This function converts the given url to an URL encoded string. All input characters that are not a-z, A-Z, 0-9, '-', '.', '_' or '~' are converted to their "URL escaped" version (NN where NN is a two-digit hexadecimal number).

Returns
true if the conversion was successful, false if it failed or the target buffer was too small.

Definition at line 362 of file http.cpp.

References Q_strncpyz().

Referenced by WEB_CGameGetURL(), WEB_GetToFile(), and WEB_GetURL().

◆ HTTP_ExtractComponents()

bool HTTP_ExtractComponents ( const char * url,
char * scheme,
size_t schemeLength,
char * host,
size_t hostLength,
char * path,
size_t pathLength,
int * port )

Extract the servername, the port and the path part of the given url.

Parameters
[in]urlThe url to extract the data from
[out]schemeThe URL scheme string http or https
[in]schemeLengthLength of the scheme buffer
[out]hostThe server target buffer
[in]hostLengthThe length of the buffer
[out]pathThe path target buffer
[in]pathLengthThe length of the buffer
[out]portThe port
Returns
true if the extracting went well, false if an error occurred

Definition at line 38 of file http.cpp.

References Com_Printf(), i, port, Q_streq, Q_strncpyz(), Q_strneq, and Q_strnull().

Referenced by HTTP_ResolvURL(), and TEST_F().

◆ HTTP_GetToFile()

bool HTTP_GetToFile ( const char * url,
FILE * file,
const char * postfields )

Downloads the given url into the given file.

Parameters
[in]urlThe url to fetch
[in]fileThe file to write the result into
[in]postfieldsSome potential POST data in the form

Definition at line 346 of file http.cpp.

References FILE, HTTP_GetURLInternal(), and OBJZERO.

Referenced by WEB_CGameDownloadFromUser(), and WEB_GetToFile().

◆ HTTP_GetURL()

bool HTTP_GetURL ( const char * url,
http_callback_t callback,
void * userdata,
const char * postfields )

Downloads the given url and return the data to the callback (optional).

Parameters
[in]urlThe url to fetch
[in]callbackThe callback to give the data to. Might also be NULL
[in]userdataThe userdata that is given to the callback
[in]postfieldsSome potential POST data

Definition at line 384 of file http.cpp.

References HTTP_GetURLInternal(), Mem_Free, OBJZERO, and dlhandle_t::tempBuffer.

Referenced by CL_QueryMasterServer(), Irc_Client_Invite_f(), Master_HeartbeatThread(), Master_Shutdown(), SV_SetMaster_f(), and WEB_GetURL().

◆ HTTP_Header()

size_t HTTP_Header ( void * ptr,
size_t size,
size_t nmemb,
void * stream )

libcurl callback to update header info.

Definition at line 126 of file http.cpp.

References dlhandle_t::file, dlhandle_t::fileSize, len, Q_strncasecmp, and Q_strncpyz().

Referenced by CL_StartHTTPDownload(), and HTTP_GetURLInternal().

◆ HTTP_PutFile()

bool HTTP_PutFile ( const char * formName,
const char * fileName,
const char * url,
const upparam_t * params )

◆ HTTP_Recv()

size_t HTTP_Recv ( void * ptr,
size_t size,
size_t nmemb,
void * stream )

libcurl callback for HTTP_GetURL

Definition at line 154 of file http.cpp.

References dlhandle_t::fileSize, Mem_AllocTypeN, Mem_Free, dlhandle_t::position, and dlhandle_t::tempBuffer.

Referenced by CL_StartHTTPDownload(), and HTTP_GetURLInternal().