|
gwenhywfar 5.10.1
|
#include <gwenhywfar/inherit.h>#include <gwenhywfar/url.h>#include <gwenhywfar/buffer.h>#include <gwenhywfar/syncio.h>#include <gwenhywfar/inetsocket.h>
Go to the source code of this file.
Macros | |
| #define | GWEN_HTTP_SESSION_FLAGS_FORCE_SSL3 0x00000001 /* deprecated, will be removed in a future release */ |
| #define | GWEN_HTTP_SESSION_FLAGS_NO_CACHE 0x00000002 |
| #define | GWEN_HTTP_SESSION_FLAGS_PASSIVE 0x00000020 /* server session */ |
| #define | GWEN_HTTP_SESSION_FLAGS_TLS_FORCE_UNSAFE_CIPHERS 0x00000008 /* deprecated, will be removed in a future release */ |
| #define | GWEN_HTTP_SESSION_FLAGS_TLS_IGN_PREMATURE_CLOSE 0x00000010 |
| #define | GWEN_HTTP_SESSION_FLAGS_TLS_ONLY_SAFE_CIPHERS 0x00000004 /* deprecated, will be removed in a future release */ |
Typedefs | |
| typedef struct GWEN_HTTP_SESSION | GWEN_HTTP_SESSION |
SyncIO Initialisation | |
After creating a connection layer (consisting of a chain of GWEN_SYNCIO's) this callback is called. AqBanking uses it to set the TLS-cert-checking callback for the TLS syncio part (GWEN_SyncIo_Tls_SetCheckCertFn), so whenever a TLS connection is established and a certificate received, that function is called. | |
| typedef int GWENHYWFAR_CB(* | GWEN_HTTPSESSION_INITSYNCIO_FN) (GWEN_HTTP_SESSION *sess, GWEN_SYNCIO *sio) |
| GWENHYWFAR_API GWEN_HTTPSESSION_INITSYNCIO_FN | GWEN_HttpSession_SetInitSyncIoFn (GWEN_HTTP_SESSION *sess, GWEN_HTTPSESSION_INITSYNCIO_FN f) |
| #define GWEN_HTTP_SESSION_FLAGS_FORCE_SSL3 0x00000001 /* deprecated, will be removed in a future release */ |
This flag forces SSLv3 connections when in HTTPS mode.
Definition at line 39 of file httpsession.h.
| #define GWEN_HTTP_SESSION_FLAGS_NO_CACHE 0x00000002 |
Definition at line 41 of file httpsession.h.
| #define GWEN_HTTP_SESSION_FLAGS_PASSIVE 0x00000020 /* server session */ |
Definition at line 49 of file httpsession.h.
| #define GWEN_HTTP_SESSION_FLAGS_TLS_FORCE_UNSAFE_CIPHERS 0x00000008 /* deprecated, will be removed in a future release */ |
Definition at line 44 of file httpsession.h.
| #define GWEN_HTTP_SESSION_FLAGS_TLS_IGN_PREMATURE_CLOSE 0x00000010 |
Definition at line 47 of file httpsession.h.
| #define GWEN_HTTP_SESSION_FLAGS_TLS_ONLY_SAFE_CIPHERS 0x00000004 /* deprecated, will be removed in a future release */ |
Definition at line 43 of file httpsession.h.
| typedef struct GWEN_HTTP_SESSION GWEN_HTTP_SESSION |
Definition at line 21 of file httpsession.h.
| typedef int GWENHYWFAR_CB(* GWEN_HTTPSESSION_INITSYNCIO_FN) (GWEN_HTTP_SESSION *sess, GWEN_SYNCIO *sio) |
Definition at line 270 of file httpsession.h.
| GWENHYWFAR_API void GWEN_HttpSession_AddFlags | ( | GWEN_HTTP_SESSION * | sess, |
| uint32_t | fl | ||
| ) |
Definition at line 189 of file httpsession.c.
| GWENHYWFAR_API void GWEN_HttpSession_Attach | ( | GWEN_HTTP_SESSION * | sess | ) |
Definition at line 127 of file httpsession.c.
| GWENHYWFAR_API int GWEN_HttpSession_ConnectionTest | ( | GWEN_HTTP_SESSION * | sess | ) |
Test-connect to the server. This function can be used to retrieve the SSL certificate from a server as the cert exchange is part of the establishing of a connection. This function connects to the server and immediately disconnects.
Definition at line 876 of file httpsession.c.
References DBG_INFO, DBG_NOTICE, GWEN_ERROR_SSL, GWEN_Gui_ProgressLog(), GWEN_LOGDOMAIN, GWEN_LoggerLevel_Error, GWEN_LoggerLevel_Notice, GWEN_SyncIo_Connect(), GWEN_SyncIo_Disconnect(), and I18N.

| GWENHYWFAR_API int GWEN_HttpSession_Fini | ( | GWEN_HTTP_SESSION * | sess | ) |
Definition at line 401 of file httpsession.c.
References GWEN_SyncIo_Disconnect(), GWEN_SyncIo_free(), and NULL.

| GWENHYWFAR_API void GWEN_HttpSession_free | ( | GWEN_HTTP_SESSION * | sess | ) |
Definition at line 136 of file httpsession.c.
References GWEN_FREE_OBJECT, GWEN_INHERIT_FINI, and GWEN_SyncIo_free().
Referenced by GWEN_HttpSession_fromSocketPassive().


| GWENHYWFAR_API GWEN_HTTP_SESSION * GWEN_HttpSession_fromSocketPassive | ( | GWEN_SOCKET * | sk, |
| const char * | proto, | ||
| int | port | ||
| ) |
Create a server HTTP session using the given socket.
The caller is responsible for freeing the object returned (if any).
| sk | socket (received via GWEN_Socket_Accept), taken over |
| proto | protocol used by this server session (either "http" or "https") |
| port | port used by this server session (in ost cases 80 for HTTP, 443 for HTTPS) |
Definition at line 64 of file httpsession.c.
References DBG_ERROR, GWEN_Gui_ExtendSyncIo(), GWEN_HTTP_SESSION_FLAGS_PASSIVE, GWEN_HttpSession_free(), GWEN_INHERIT_INIT, GWEN_LOGDOMAIN, GWEN_NEW_OBJECT, GWEN_SyncIo_AddFlags(), GWEN_SYNCIO_FLAGS_PASSIVE, GWEN_SyncIo_GetBaseIo(), GWEN_SyncIo_Socket_TakeOver(), and NULL.

| GWENHYWFAR_API GWEN_HTTP_SESSION * GWEN_HttpSession_fromSyncIoPassive | ( | GWEN_SYNCIO * | sio | ) |
Create a server HTTP session using the given syncio.
The caller is responsible for freeing the object returned (if any).
| sio | synIo object, taken over |
Definition at line 104 of file httpsession.c.
References GWEN_HTTP_SESSION_FLAGS_PASSIVE, GWEN_INHERIT_INIT, GWEN_NEW_OBJECT, GWEN_SyncIo_AddFlags(), GWEN_SYNCIO_FLAGS_PASSIVE, and GWEN_SyncIo_GetBaseIo().

| GWENHYWFAR_API uint32_t GWEN_HttpSession_GetFlags | ( | const GWEN_HTTP_SESSION * | sess | ) |
Definition at line 169 of file httpsession.c.
| GWENHYWFAR_API const char * GWEN_HttpSession_GetHttpContentType | ( | const GWEN_HTTP_SESSION * | sess | ) |
Definition at line 233 of file httpsession.c.
| GWENHYWFAR_API const char * GWEN_HttpSession_GetHttpUserAgent | ( | const GWEN_HTTP_SESSION * | sess | ) |
Definition at line 209 of file httpsession.c.
| GWENHYWFAR_API int GWEN_HttpSession_GetHttpVMajor | ( | const GWEN_HTTP_SESSION * | sess | ) |
Definition at line 257 of file httpsession.c.
| GWENHYWFAR_API int GWEN_HttpSession_GetHttpVMinor | ( | const GWEN_HTTP_SESSION * | sess | ) |
Definition at line 277 of file httpsession.c.
| GWENHYWFAR_API int GWEN_HttpSession_Init | ( | GWEN_HTTP_SESSION * | sess | ) |
Definition at line 300 of file httpsession.c.
References _setHostHeaderFromUrl(), DBG_ERROR, DBG_INFO, GWEN_DB_FLAGS_OVERWRITE_VARS, GWEN_DB_SetCharValue(), GWEN_DB_SetIntValue(), GWEN_ERROR_INTERNAL, GWEN_ERROR_INVALID, GWEN_ERROR_NOT_IMPLEMENTED, GWEN_Gui_GetSyncIo(), GWEN_HTTP_SESSION_FLAGS_NO_CACHE, GWEN_HTTP_SESSION_FLAGS_PASSIVE, GWEN_HTTP_SESSION_FLAGS_TLS_IGN_PREMATURE_CLOSE, GWEN_HttpSession_InitSyncIo(), GWEN_LOGDOMAIN, GWEN_SyncIo_AddFlags(), GWEN_SyncIo_free(), GWEN_SyncIo_GetBaseIoByTypeName(), GWEN_SyncIo_GetTypeName(), GWEN_SyncIo_Http_GetDbHeaderOut(), GWEN_SYNCIO_HTTP_TYPE, GWEN_SYNCIO_TLS_FLAGS_ADD_TRUSTED_CAS, GWEN_SYNCIO_TLS_FLAGS_ALLOW_V1_CA_CRT, GWEN_SYNCIO_TLS_FLAGS_IGN_PREMATURE_CLOSE, GWEN_SYNCIO_TLS_TYPE, and NULL.

| GWENHYWFAR_API GWEN_HTTP_SESSION * GWEN_HttpSession_new | ( | const char * | url, |
| const char * | defaultProto, | ||
| int | defaultPort | ||
| ) |
Create a client HTTP session (i.e. used to connect to a server).
The caller is responsible for freeing the object returned (if any).
| url | URL of the server to connect to later |
| defaultProto | default protocol if not specified by the given url (e.g. "https") |
| defaultPort | default TCP port if not specified by the given url |
Definition at line 45 of file httpsession.c.
References GWEN_INHERIT_INIT, and GWEN_NEW_OBJECT.
| GWENHYWFAR_API int GWEN_HttpSession_RecvCommand | ( | GWEN_HTTP_SESSION * | sess, |
| GWEN_DB_NODE * | dbCommandAndHeader, | ||
| GWEN_BUFFER * | buf | ||
| ) |
This function receives a command packet from a client.
| sess | pointer to session object |
| dbCommandAndHeader | on currect receiption a subgroup "command" is created which contains the command parameters receives and a subgroup "header" is created which contains the last HTTP header received |
| buf | buffer to receive possible HTTP body data |
Definition at line 685 of file httpsession.c.
References DBG_ERROR, DBG_INFO, GWEN_Buffer_Crop(), GWEN_Buffer_GetPos(), GWEN_DB_AddGroupChildren(), GWEN_DB_FLAGS_OVERWRITE_GROUPS, GWEN_DB_GetGroup(), GWEN_ERROR_INVALID, GWEN_Gui_ProgressLog(), GWEN_HTTP_SESSION_FLAGS_PASSIVE, GWEN_HttpSession__RecvPacket(), GWEN_LOGDOMAIN, GWEN_LoggerLevel_Debug, GWEN_SyncIo_Disconnect(), GWEN_SyncIo_Http_GetDbCommandIn(), GWEN_SyncIo_Http_GetDbHeaderIn(), and I18N.

| GWENHYWFAR_API int GWEN_HttpSession_RecvPacket | ( | GWEN_HTTP_SESSION * | sess, |
| GWEN_BUFFER * | buf | ||
| ) |
This function receives a response packet from the server and closes the connection. It expects the connection to be established by GWEN_HttpSession_SendPacket().
Definition at line 642 of file httpsession.c.
References DBG_INFO, GWEN_Buffer_Crop(), GWEN_Buffer_GetPos(), GWEN_Gui_ProgressLog(), GWEN_HttpSession__RecvPacket(), GWEN_LOGDOMAIN, GWEN_LoggerLevel_Debug, GWEN_SyncIo_Disconnect(), and I18N.

| GWENHYWFAR_API int GWEN_HttpSession_RecvPacketToFile | ( | GWEN_HTTP_SESSION * | sess, |
| const char * | fname | ||
| ) |
Definition at line 796 of file httpsession.c.
References DBG_INFO, GWEN_Gui_ProgressLog(), GWEN_HttpSession__RecvPacketToSio(), GWEN_LOGDOMAIN, GWEN_LoggerLevel_Debug, GWEN_SyncIo_AddFlags(), GWEN_SyncIo_Connect(), GWEN_SyncIo_Disconnect(), GWEN_SyncIo_File_CreationMode_CreateAlways, GWEN_SYNCIO_FILE_FLAGS_GREAD, GWEN_SYNCIO_FILE_FLAGS_GWRITE, GWEN_SYNCIO_FILE_FLAGS_READ, GWEN_SYNCIO_FILE_FLAGS_UREAD, GWEN_SYNCIO_FILE_FLAGS_UWRITE, GWEN_SYNCIO_FILE_FLAGS_WRITE, GWEN_SyncIo_File_new(), GWEN_SyncIo_Flush(), GWEN_SyncIo_free(), and I18N.

| GWENHYWFAR_API int GWEN_HttpSession_SendPacket | ( | GWEN_HTTP_SESSION * | sess, |
| const char * | httpCommand, | ||
| const uint8_t * | buf, | ||
| uint32_t | blen | ||
| ) |
This function connects to the server and then sends the given message. The buffer given as argument to this function must only contain the raw data (i.e. the HTTP body, no header).
| sess | http session object |
| httpCommand | HTTP command to send (e.g. "GET", "POST") |
| buf | pointer to the http body data to send |
| blen | size of the http body data to send (might be 0) |
Definition at line 417 of file httpsession.c.
References DBG_INFO, DBG_NOTICE, GWEN_DB_FLAGS_OVERWRITE_VARS, GWEN_DB_SetCharValue(), GWEN_DB_SetIntValue(), GWEN_ERROR_SSL, GWEN_Gui_ProgressLog(), GWEN_Gui_ProgressLog2(), GWEN_LOGDOMAIN, GWEN_LoggerLevel_Debug, GWEN_LoggerLevel_Error, GWEN_SyncIo_Connect(), GWEN_SyncIo_Disconnect(), GWEN_SyncIo_Http_GetDbCommandOut(), GWEN_SyncIo_Http_GetDbHeaderOut(), GWEN_SyncIo_WriteForced(), and I18N.

| GWENHYWFAR_API int GWEN_HttpSession_SendStatus | ( | GWEN_HTTP_SESSION * | sess, |
| int | resultCode, | ||
| const char * | resultText, | ||
| const uint8_t * | buf, | ||
| uint32_t | blen | ||
| ) |
This function sends the given response (only usable in PASSIVE mode, i.e. server mode) and closes the connection. The buffer given as argument to this function must only contain the raw data (i.e. the HTTP body, no header).
| sess | http session object |
| resultCode | HTTP result code to send |
| resultText | HTTP result text to send |
| buf | pointer to the http body data to send |
| blen | size of the http body data to send (might be 0) |
Definition at line 501 of file httpsession.c.
References DBG_ERROR, DBG_INFO, GWEN_DB_FLAGS_OVERWRITE_VARS, GWEN_DB_SetCharValue(), GWEN_DB_SetIntValue(), GWEN_ERROR_INVALID, GWEN_Gui_ProgressLog(), GWEN_Gui_ProgressLog2(), GWEN_HTTP_SESSION_FLAGS_PASSIVE, GWEN_LOGDOMAIN, GWEN_LoggerLevel_Debug, GWEN_LoggerLevel_Error, GWEN_SyncIo_Disconnect(), GWEN_SyncIo_Http_GetDbHeaderOut(), GWEN_SyncIo_Http_GetDbStatusOut(), GWEN_SyncIo_WriteForced(), and I18N.

| GWENHYWFAR_API void GWEN_HttpSession_SetFlags | ( | GWEN_HTTP_SESSION * | sess, |
| uint32_t | fl | ||
| ) |
Definition at line 179 of file httpsession.c.
| GWENHYWFAR_API void GWEN_HttpSession_SetHttpContentType | ( | GWEN_HTTP_SESSION * | sess, |
| const char * | s | ||
| ) |
Definition at line 243 of file httpsession.c.
References NULL.
| GWENHYWFAR_API void GWEN_HttpSession_SetHttpUserAgent | ( | GWEN_HTTP_SESSION * | sess, |
| const char * | s | ||
| ) |
Definition at line 219 of file httpsession.c.
References NULL.
| GWENHYWFAR_API void GWEN_HttpSession_SetHttpVMajor | ( | GWEN_HTTP_SESSION * | sess, |
| int | i | ||
| ) |
Definition at line 267 of file httpsession.c.
| GWENHYWFAR_API void GWEN_HttpSession_SetHttpVMinor | ( | GWEN_HTTP_SESSION * | sess, |
| int | i | ||
| ) |
Definition at line 287 of file httpsession.c.
| GWENHYWFAR_API GWEN_HTTPSESSION_INITSYNCIO_FN GWEN_HttpSession_SetInitSyncIoFn | ( | GWEN_HTTP_SESSION * | sess, |
| GWEN_HTTPSESSION_INITSYNCIO_FN | f | ||
| ) |
Definition at line 157 of file httpsession.c.
| GWENHYWFAR_API void GWEN_HttpSession_SubFlags | ( | GWEN_HTTP_SESSION * | sess, |
| uint32_t | fl | ||
| ) |
Definition at line 199 of file httpsession.c.