written more http code
This commit is contained in:
@ -303,9 +303,9 @@ qse_printf (QSE_T("HEADER OK %d[%S] %d[%S]\n"), (int)QSE_HTB_KLEN(pair), QSE_HT
|
||||
return QSE_HTB_WALK_FORWARD;
|
||||
}
|
||||
|
||||
static int capture_param (void* ctx, const qse_mcstr_t* key, const qse_mcstr_t* val)
|
||||
static int capture_param (qse_htrd_t* http, const qse_mcstr_t* key, const qse_mcstr_t* val)
|
||||
{
|
||||
qse_printf (QSE_T("PARAM [%.*S] => [%.*S] \n"), (int)key->len, key->ptr, (int)val->len, val->ptr);
|
||||
qse_printf (QSE_T("PARAM %d[%S] => %d[%S] \n"), (int)key->len, key->ptr, (int)val->len, val->ptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -322,9 +322,9 @@ qse_printf (QSE_T("REQUEST ==> [%S] version[%d.%d] method[%d]\n"),
|
||||
qse_htre_getminorversion(req),
|
||||
qse_htre_getqmethod(req)
|
||||
);
|
||||
if (qse_htre_getqparamstrlen(req) > 0)
|
||||
if (qse_htre_getqparamlen(req) > 0)
|
||||
{
|
||||
qse_printf (QSE_T("PARAMS ==> [%S]\n"), qse_htre_getqparamstrptr(req));
|
||||
qse_printf (QSE_T("PARAMS ==> [%S]\n"), qse_htre_getqparamptr(req));
|
||||
}
|
||||
|
||||
qse_htb_walk (&http->re.hdrtab, walk, QSE_NULL);
|
||||
@ -340,14 +340,10 @@ qse_printf (QSE_T("content = [%.*S]\n"),
|
||||
if (method == QSE_HTTP_GET || method == QSE_HTTP_POST)
|
||||
{
|
||||
int fd;
|
||||
qse_mchar_t* paramstr;
|
||||
|
||||
qse_printf (QSE_T("BEGIN SCANNING PARAM STR\n"));
|
||||
|
||||
paramstr = qse_htre_getqparamstrptr(req); /* if it is null, ? wasn't even provided */
|
||||
if (paramstr != QSE_NULL && qse_scanhttpparamstr (paramstr, capture_param, client) <= -1)
|
||||
//if (qse_htrd_scanqparam (http, qse_htre_getqparamcstr(req)) <= -1)
|
||||
if (qse_htrd_scanqparam (http, QSE_NULL) <= -1)
|
||||
{
|
||||
qse_printf (QSE_T("END SCANNING PARAM STR WITH ERROR\n"));
|
||||
const char* msg = "<html><head><title>INTERNAL SERVER ERROR</title></head><body><b>INTERNAL SERVER ERROR</b></body></html>";
|
||||
if (format_and_do (enqueue_format, client,
|
||||
"HTTP/%d.%d 500 Internal Server Error\r\nContent-Length: %d\r\n\r\n%s\r\n\r\n",
|
||||
@ -360,7 +356,14 @@ qse_printf (QSE_T("failed to push action....\n"));
|
||||
}
|
||||
}
|
||||
|
||||
qse_printf (QSE_T("END SCANNING PARAM STR WITH SUCCESS\n"));
|
||||
if (method == QSE_HTTP_POST)
|
||||
{
|
||||
qse_printf (QSE_T("BEGIN FORM FIELDS=============\n"));
|
||||
if (qse_htrd_scanqparam (http, qse_htre_getcontentcstr(req)) <= -1)
|
||||
{
|
||||
}
|
||||
qse_printf (QSE_T("END FORM FIELDS=============\n"));
|
||||
}
|
||||
|
||||
fd = open (qse_htre_getqpathptr(req), O_RDONLY);
|
||||
if (fd <= -1)
|
||||
@ -416,10 +419,12 @@ qse_printf (QSE_T("empty file....\n"));
|
||||
|
||||
char text[128];
|
||||
snprintf (text, sizeof(text),
|
||||
"HTTP/%d.%d 200 OK\r\nContent-Length: %llu\r\n\r\n",
|
||||
"HTTP/%d.%d 200 OK\r\nContent-Length: %llu\r\nContent-Location: %s\r\n\r\n",
|
||||
qse_htre_getmajorversion(req),
|
||||
qse_htre_getminorversion(req),
|
||||
(unsigned long long)st.st_size);
|
||||
(unsigned long long)st.st_size,
|
||||
qse_htre_getqpathptr(req)
|
||||
);
|
||||
|
||||
#if 0
|
||||
if (enqueue_sendfmt_locked (client,
|
||||
@ -550,7 +555,8 @@ qse_htrd_recbs_t http_recbs =
|
||||
receive_octets,
|
||||
handle_request,
|
||||
handle_response,
|
||||
handle_expect_continue
|
||||
handle_expect_continue,
|
||||
capture_param
|
||||
};
|
||||
|
||||
int mkserver (const char* portstr)
|
||||
|
Reference in New Issue
Block a user