提交 93cb6386 编写于 作者: F freemine

body process

上级 d9c04b18
...@@ -337,6 +337,7 @@ static void on_header_field(void *arg, const char *key, const char *val) { ...@@ -337,6 +337,7 @@ static void on_header_field(void *arg, const char *key, const char *val) {
if (pParser->failed) return; if (pParser->failed) return;
D("==key:[%s], val:[%s]==", key, val);
int avail = sizeof(pParser->buffer) - (pParser->pLast - pParser->buffer); int avail = sizeof(pParser->buffer) - (pParser->pLast - pParser->buffer);
int n = snprintf(pParser->pLast, avail, int n = snprintf(pParser->pLast, avail,
"%s: %s\r\n", key, val); "%s: %s\r\n", key, val);
...@@ -350,7 +351,7 @@ static void on_header_field(void *arg, const char *key, const char *val) { ...@@ -350,7 +351,7 @@ static void on_header_field(void *arg, const char *key, const char *val) {
break; break;
} }
pParser->bufsize += n; pParser->bufsize += n;
pParser->pCur = pParser->pLast; pParser->pCur = pParser->pLast + n;
if (!httpParseHead(pContext)) { if (!httpParseHead(pContext)) {
httpDebug("context:%p, fd:%d, ip:%s, thread:%s, accessTimes:%d, on_header_field(%s,%s), parse head failed", httpDebug("context:%p, fd:%d, ip:%s, thread:%s, accessTimes:%d, on_header_field(%s,%s), parse head failed",
...@@ -372,9 +373,19 @@ static void on_body(void *arg, const char *chunk, size_t len) { ...@@ -372,9 +373,19 @@ static void on_body(void *arg, const char *chunk, size_t len) {
if (pParser->failed) return; if (pParser->failed) return;
if (pParser->data.pos == 0) pParser->data.pos = pParser->pLast; if (pParser->data.pos == 0) {
pParser->data.pos = pParser->pLast;
pParser->data.len = 0;
}
A("not implemented yet"); int avail = sizeof(pParser->buffer) - (pParser->pLast - pParser->buffer);
if (len+1>=avail) {
pParser->failed |= EHTTP_CONTEXT_PROCESS_FAILED;
return;
}
memcpy(pParser->pLast, chunk, len);
pParser->pLast += len;
pParser->data.len += len;
} }
static void on_end(void *arg) { static void on_end(void *arg) {
......
...@@ -138,7 +138,7 @@ static bool httpDecompressData(HttpContext *pContext) { ...@@ -138,7 +138,7 @@ static bool httpDecompressData(HttpContext *pContext) {
} }
static bool httpReadData(HttpContext *pContext) { static bool httpReadData(HttpContext *pContext) {
if (0) return ehttpReadData(pContext); if (1) return ehttpReadData(pContext);
if (!pContext->parsed) { if (!pContext->parsed) {
httpInitContext(pContext); httpInitContext(pContext);
...@@ -448,7 +448,9 @@ static bool ehttpReadData(HttpContext *pContext) { ...@@ -448,7 +448,9 @@ static bool ehttpReadData(HttpContext *pContext) {
return false; return false;
} }
if (pContext->parsed) { if (pContext->parsed) {
int ret = httpCheckReadCompleted(pContext); // int ret = httpCheckReadCompleted(pContext);
// already done in ehttp_parser
int ret = HTTP_CHECK_BODY_SUCCESS;
if (ret == HTTP_CHECK_BODY_CONTINUE) { if (ret == HTTP_CHECK_BODY_CONTINUE) {
//httpDebug("context:%p, fd:%d, ip:%s, not finished yet, wait another event", pContext, pContext->fd, pContext->ipstr); //httpDebug("context:%p, fd:%d, ip:%s, not finished yet, wait another event", pContext, pContext->fd, pContext->ipstr);
httpReleaseContext(pContext); httpReleaseContext(pContext);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册