1 /***********************************************************************************************************************************
2 HTTP Session
3
4 HTTP sessions are created by calling httpClientOpen(), which is currently done exclusively by the HttpRequest object.
5 ***********************************************************************************************************************************/
6 #ifndef COMMON_IO_HTTP_SESSION_H
7 #define COMMON_IO_HTTP_SESSION_H
8
9 /***********************************************************************************************************************************
10 Object type
11 ***********************************************************************************************************************************/
12 typedef struct HttpSession HttpSession;
13
14 #include "common/io/read.h"
15 #include "common/io/http/client.h"
16 #include "common/io/session.h"
17 #include "common/io/write.h"
18 #include "common/type/object.h"
19
20 /***********************************************************************************************************************************
21 Constructors
22 ***********************************************************************************************************************************/
23 HttpSession *httpSessionNew(HttpClient *client, IoSession *session);
24
25 /***********************************************************************************************************************************
26 Functions
27 ***********************************************************************************************************************************/
28 // Move to a new parent mem context
29 __attribute__((always_inline)) static inline HttpSession *
httpSessionMove(HttpSession * const this,MemContext * const parentNew)30 httpSessionMove(HttpSession *const this, MemContext *const parentNew)
31 {
32 return objMove(this, parentNew);
33 }
34
35 // Work with the session has finished cleanly and it can be reused
36 void httpSessionDone(HttpSession *this);
37
38 /***********************************************************************************************************************************
39 Getters/Setters
40 ***********************************************************************************************************************************/
41 // Read interface
42 IoRead *httpSessionIoRead(HttpSession *this);
43
44 // Write interface
45 IoWrite *httpSessionIoWrite(HttpSession *this);
46
47 /***********************************************************************************************************************************
48 Destructor
49 ***********************************************************************************************************************************/
50 __attribute__((always_inline)) static inline void
httpSessionFree(HttpSession * const this)51 httpSessionFree(HttpSession *const this)
52 {
53 objFree(this);
54 }
55
56 /***********************************************************************************************************************************
57 Macros for function logging
58 ***********************************************************************************************************************************/
59 #define FUNCTION_LOG_HTTP_SESSION_TYPE \
60 HttpSession *
61 #define FUNCTION_LOG_HTTP_SESSION_FORMAT(value, buffer, bufferSize) \
62 objToLog(value, "HttpSession", buffer, bufferSize)
63
64 #endif
65