aqhome: more work on http server.
This commit is contained in:
@@ -70,6 +70,7 @@ void AQH_HttpEndpoint_Extend(GWEN_MSG_ENDPOINT *ep, uint32_t flags)
|
||||
GWEN_NEW_OBJECT(AQH_ENDPOINT_HTTP, xep);
|
||||
GWEN_INHERIT_SETDATA(GWEN_MSG_ENDPOINT, AQH_ENDPOINT_HTTP, ep, xep, _freeData);
|
||||
xep->readMode=AQH_EndpointHttpd_ReadMode_Command;
|
||||
xep->flags=flags;
|
||||
|
||||
xep->addSocketsFn=GWEN_MsgEndpoint_SetAddSocketsFn(ep, _addSockets);
|
||||
xep->checkSocketsFn=GWEN_MsgEndpoint_SetCheckSocketsFn(ep, _checkSockets);
|
||||
@@ -325,7 +326,9 @@ int _distributeBufferInCommandMode(GWEN_MSG_ENDPOINT *ep, const uint8_t *bufferP
|
||||
_finishMessageAndStartNext(ep);
|
||||
return rv;
|
||||
}
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Command line complete, advancing to header read mode");
|
||||
DBG_INFO(AQH_LOGDOMAIN,
|
||||
"Command line complete, advancing to header read mode (start: %d)",
|
||||
GWEN_Buffer_GetPos(xep->currentReadBuffer));
|
||||
xep->readMode=AQH_EndpointHttpd_ReadMode_Headers;
|
||||
xep->currentHeaderPos=GWEN_Buffer_GetPos(xep->currentReadBuffer);
|
||||
}
|
||||
@@ -368,7 +371,7 @@ int _distributeBufferInHeaderMode(GWEN_MSG_ENDPOINT *ep, const uint8_t *bufferPt
|
||||
AQH_ENDPOINT_HTTP *xep;
|
||||
int lineLength;
|
||||
|
||||
/* line complete, TODO: parse status/command line */
|
||||
/* line complete, parse status/command line */
|
||||
rv=-rv;
|
||||
xep=GWEN_INHERIT_GETDATA(GWEN_MSG_ENDPOINT, AQH_ENDPOINT_HTTP, ep);
|
||||
|
||||
@@ -379,7 +382,7 @@ int _distributeBufferInHeaderMode(GWEN_MSG_ENDPOINT *ep, const uint8_t *bufferPt
|
||||
int contentLength;
|
||||
|
||||
/* Empty line received, TODO: parse header */
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Empty header line received, end of header reached.");
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Empty header line received, end of header reached (header pos: %d).", xep->currentHeaderPos);
|
||||
copyOfHeader=strdup(GWEN_Buffer_GetStart(xep->currentReadBuffer)+xep->currentHeaderPos);
|
||||
xep->dbCurrentReadHeader=GWEN_DB_Group_new("header");
|
||||
if (_parseHeader(copyOfHeader, xep->dbCurrentReadHeader)<0) {
|
||||
@@ -498,10 +501,14 @@ void _finishMessageAndStartNext(GWEN_MSG_ENDPOINT *ep)
|
||||
xep->dbCurrentReadCommand=NULL;
|
||||
xep->dbCurrentReadHeader=NULL;
|
||||
|
||||
if (xep->flags & AQH_ENDPOINT_HTTP_FLAGS_PASSIVE)
|
||||
if (xep->flags & AQH_ENDPOINT_HTTP_FLAGS_PASSIVE) {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Passive connection");
|
||||
xep->readMode=AQH_EndpointHttpd_ReadMode_Command;
|
||||
else
|
||||
}
|
||||
else {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "Active connection");
|
||||
xep->readMode=AQH_EndpointHttpd_ReadMode_Status;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -571,7 +578,7 @@ int _parseHeader(char *bufferPtr, GWEN_DB_NODE *db)
|
||||
p++;
|
||||
pVarEnd=p;
|
||||
if (*p!=':') {
|
||||
DBG_INFO(AQH_LOGDOMAIN, "No separator after variable name in received header");
|
||||
DBG_INFO(AQH_LOGDOMAIN, "No separator after variable name in received header (var: [%s])", pVarBegin);
|
||||
return GWEN_ERROR_BAD_DATA;
|
||||
}
|
||||
*pVarEnd=0;
|
||||
|
||||
Reference in New Issue
Block a user