#include "Build.h"
#include "HTTP.h"
#include "Authentication/base64.h"
#include "Authentication/ntlm.h"
#include "Authentication/digest.h"
#include <sys/timeb.h>
#include <process.h>
#include <time.h>
#include <wininet.h>
Go to the source code of this file.
Data Structures | |
struct | _HTTPmapping_struct_ |
struct | conexiones |
struct | _hhandle |
This struct is the information used by FHScan to manage HTTP requests. This struct does not manage sockets, however a pointer to an STABLISHED_CONNECTION is provided. For the user point of view, this handle is only a pointer. an user must not tweak data stored in this struct. More... | |
Defines | |
#define | MAX_OPEN_CONNECTIONS 512 |
#define | PURGETIME 20 |
#define | MAX_OPEN_CONNETIONS_AGAINST_SAME_HOST 10 |
#define | BUFFSIZE 4096 |
#define | TARGET_FREE 0 |
#define | MAX_INACTIVE_CONNECTION 10000000 *PURGETIME |
#define | MAXIMUM_OPENED_HANDLES 1024 |
Typedefs | |
typedef struct _HTTPmapping_struct_ | HTTPIOMapping |
typedef struct _HTTPmapping_struct_ * | PHTTPIOMapping |
typedef struct conexiones | STABLISHED_CONNECTION |
typedef struct _hhandle * | PHHANDLE |
Functions | |
int | HTTPCoreCancelHTTPRequest (HTTPHANDLE HTTPHandle, int what) |
This function is used to clean the connection struct and cancel I/O request. | |
void | FreeConnection (STABLISHED_CONNECTION *connection) |
This function is used to clean the status of a connection struct when the conexion socket is closed or when there is a problem reading the HTTP stream (like timeouts). | |
static void * | CleanConnectionTable (void *foo) |
static unsigned int | GetNumberOfConnectionsAgainstTarget (PHHANDLE HTTPHandle) |
static int | GetFirstIdleConnectionAgainstTarget (PHHANDLE HTTPHandle) |
static int | GetFirstUnUsedConnectionAgainstTarget (PHHANDLE HTTPHandle) |
int | RemovePipeLineRequest (STABLISHED_CONNECTION *connection) |
This function Adds a pending request struct to the connection pool. | |
static unsigned long | AddPipeLineRequest (STABLISHED_CONNECTION *connection, PHTTP_DATA request) |
static STABLISHED_CONNECTION * | GetSocketConnection (PHHANDLE HTTPHandle, PHTTP_DATA request, unsigned long *id) |
PHTTP_DATA | DispatchHTTPRequest (PHHANDLE HTTPHandle, PHTTP_DATA request) |
int | InitHTTPApiCore (void) |
This function is used to start the HTTP Core Engine and must be called only once. | |
void | CloseHTTPApiCore (void) |
This function stops the HTTP Core Engine. | |
PHTTP_DATA | InitHTTPData (char *header, char *postdata) |
This function Initializes an HTTP_DATA struct with the headers and and data sent or returned by a client or an http server. | |
void | FreeHTTPData (HTTP_DATA *data) |
This function deallocates the memory of an an HTTP_DATA struct. |
#define BUFFSIZE 4096 |
#define MAX_INACTIVE_CONNECTION 10000000 *PURGETIME |
Definition at line 51 of file HTTPCore.h.
#define MAX_OPEN_CONNECTIONS 512 |
Definition at line 46 of file HTTPCore.h.
#define MAX_OPEN_CONNETIONS_AGAINST_SAME_HOST 10 |
Definition at line 48 of file HTTPCore.h.
#define MAXIMUM_OPENED_HANDLES 1024 |
Definition at line 52 of file HTTPCore.h.
#define PURGETIME 20 |
Definition at line 47 of file HTTPCore.h.
#define TARGET_FREE 0 |
Definition at line 50 of file HTTPCore.h.
Referenced by FreeConnection(), and GetFirstUnUsedConnectionAgainstTarget().
typedef struct _HTTPmapping_struct_ HTTPIOMapping |
typedef struct _HTTPmapping_struct_ * PHTTPIOMapping |
typedef struct conexiones STABLISHED_CONNECTION |
static unsigned long AddPipeLineRequest | ( | STABLISHED_CONNECTION * | connection, | |
PHTTP_DATA | request | |||
) | [static] |
static void* CleanConnectionTable | ( | void * | foo | ) | [static] |
void CloseHTTPApiCore | ( | void | ) |
This function stops the HTTP Core Engine.
As CallBacks table will be erased (This also include user registered callbacks)
Definition at line 578 of file HTTPCore.cpp.
Referenced by CloseHTTPApi().
PHTTP_DATA DispatchHTTPRequest | ( | PHHANDLE | HTTPHandle, | |
PHTTP_DATA | request | |||
) |
This function gets an stablished connection against the remote host, sends the generated HTTP the request and Waits for a response. Callbacks are called at this point.
HTTPHandle | Handle to the remote host. | |
request | struct that stores both header and post data that will be delivered to the remote HTTP Host. |
This function shouldnt be called remotely as for example, does not suport authentication. Instead, use SendHTTPRequest() exported at the public interface.
Registered CallBacks are called from this point.
Definition at line 455 of file HTTPCore.cpp.
Referenced by SendHttpRequest().
void FreeConnection | ( | STABLISHED_CONNECTION * | connection | ) |
This function is used to clean the status of a connection struct when the conexion socket is closed or when there is a problem reading the HTTP stream (like timeouts).
connection | Pointer to a CONEXION struct |
If there are pending pipelined requests this function will also reconnect the socket and send those requests to the server
Definition at line 67 of file HTTPCore.cpp.
References conexiones::datasock, _data::Header, conexiones::io, conexiones::NeedSSL, conexiones::NumberOfRequests, conexiones::PENDING_PIPELINE_REQUESTS, conexiones::PIPELINE_Request, conexiones::port, RemovePipeLineRequest(), SendHTTPRequestData(), StablishConnection(), conexiones::target, TARGET_FREE, and conexiones::tlastused.
Referenced by GetSocketConnection(), and ReadHTTPResponseData().
void FreeHTTPData | ( | HTTP_DATA * | data | ) |
This function deallocates the memory of an an HTTP_DATA struct.
data | pointer to an HTTP_DATA struct allocated by a previous call to InitHTTPData(). |
Definition at line 652 of file HTTPCore.cpp.
Referenced by FreeRequest(), and ParseReturnedBuffer().
static int GetFirstIdleConnectionAgainstTarget | ( | PHHANDLE | HTTPHandle | ) | [static] |
static int GetFirstUnUsedConnectionAgainstTarget | ( | PHHANDLE | HTTPHandle | ) | [static] |
static unsigned int GetNumberOfConnectionsAgainstTarget | ( | PHHANDLE | HTTPHandle | ) | [static] |
static STABLISHED_CONNECTION* GetSocketConnection | ( | PHHANDLE | HTTPHandle, | |
PHTTP_DATA | request, | |||
unsigned long * | id | |||
) | [static] |
int HTTPCoreCancelHTTPRequest | ( | HTTPHANDLE | HTTPHandle, | |
int | what | |||
) |
This function is used to clean the connection struct and cancel I/O request.
HTTPHandle | Handle of the remote connection. | |
what | Cancel only the current request HTTP_REQUEST_CURRENT or blocks all connections against the remote HTTP host with HTTP_REQUEST_ALL. |
Definition at line 41 of file HTTPCore.cpp.
References _hhandle::conexion, conexiones::datasock, lock, LockMutex(), conexiones::NumberOfRequests, and UnLockMutex().
Referenced by CancelHttpRequest().
int InitHTTPApiCore | ( | void | ) |
This function is used to start the HTTP Core Engine and must be called only once.
Under Win32, WSA Sockets are also initialized.
Supported Core Callbacks must be registered here. Example Chunk encoding, gzip compression..
Definition at line 517 of file HTTPCore.cpp.
Referenced by InitHTTPApi().
PHTTP_DATA InitHTTPData | ( | char * | header, | |
char * | postdata | |||
) |
This function Initializes an HTTP_DATA struct with the headers and and data sent or returned by a client or an http server.
header | pointer to an string that contains HTTP headers. This value can be null | |
postdata | pointer to an string that contains HTTP data. This value can be null. |
Definition at line 622 of file HTTPCore.cpp.
Referenced by ReadHTTPResponseData(), and SendHttpRequest().
int RemovePipeLineRequest | ( | STABLISHED_CONNECTION * | connection | ) |
This function Adds a pending request struct to the connection pool.
connection | CONEXION struct returned by a previous call to GetSocketConnection. From this connection the first added request struct will be removed (FIFO) |
Definition at line 247 of file HTTPCore.cpp.
Referenced by FreeConnection(), and ReadHTTPResponseData().