6 #include "xmlrpc-c/util_int.h"
7 #include "xmlrpc-c/string_int.h"
8 #include "xmlrpc-c/abyss.h"
18 SessionRefillBuffer(TSession * const sessionP) {
19 /*----------------------------------------------------------------------------
20 Get the next chunk of HTTP request body from the connection into
23 I.e. read data from the socket.
24 -----------------------------------------------------------------------------*/
25 struct _TServer * const srvP = sessionP->conn->server->srvP;
28 failed = FALSE; /* initial value */
30 /* Reset our read buffer & flush data from previous reads. */
31 ConnReadInit(sessionP->conn);
33 if (sessionP->continueRequired)
34 failed = !HTTPWriteContinue(sessionP);
37 sessionP->continueRequired = FALSE;
39 /* Read more network data into our buffer. If we encounter a
40 timeout, exit immediately. We're very forgiving about the
41 timeout here. We allow a full timeout per network read, which
42 would allow somebody to keep a connection alive nearly
43 indefinitely. But it's hard to do anything intelligent here
44 without very complicated code.
46 failed = !ConnRead(sessionP->conn, srvP->timeout);
54 SessionReadDataAvail(TSession * const sessionP) {
56 return sessionP->conn->buffersize - sessionP->conn->bufferpos;
63 SessionGetReadData(TSession * const sessionP,
65 const char ** const outStartP,
66 size_t * const outLenP) {
67 /*----------------------------------------------------------------------------
68 Extract some HTTP request body which the server has read and
69 buffered for the session. Don't get or wait for any data that has
70 not yet arrived. Do not return more than 'max'.
72 We return a pointer to the first byte as *outStartP, and the length in
73 bytes as *outLenP. The memory pointed to belongs to the session.
74 -----------------------------------------------------------------------------*/
75 uint32_t const bufferPos = sessionP->conn->bufferpos;
77 *outStartP = &sessionP->conn->buffer[bufferPos];
79 assert(bufferPos <= sessionP->conn->buffersize);
81 *outLenP = MIN(max, sessionP->conn->buffersize - bufferPos);
83 /* move pointer past the bytes we are returning */
84 sessionP->conn->bufferpos += *outLenP;
86 assert(sessionP->conn->bufferpos <= sessionP->conn->buffersize);
92 SessionGetRequestInfo(TSession * const sessionP,
93 const TRequestInfo ** const requestInfoPP) {
95 *requestInfoPP = &sessionP->request_info;
101 SessionLog(TSession * const sessionP) {
105 if (!sessionP->validRequest)
108 const char * const user = sessionP->request_info.user;
110 const char * logline;
113 DateToLogString(&sessionP->date, date);
115 xmlrpc_asprintf(&logline, "%d.%d.%d.%d - %s - [%s] \"%s\" %d %d",
116 IPB1(sessionP->conn->peerip),
117 IPB2(sessionP->conn->peerip),
118 IPB3(sessionP->conn->peerip),
119 IPB4(sessionP->conn->peerip),
122 sessionP->request_info.requestline,
124 sessionP->conn->outbytes
127 LogWrite(sessionP->conn->server, logline);
129 xmlrpc_strfree(logline);