fixed protocol upgrade handling

This commit is contained in:
hyung-hwan 2014-10-08 16:18:52 +00:00
parent 5edd4f38cf
commit 0ae76bd5ed

View File

@ -685,11 +685,22 @@ static int proxy_htrd_peek_peer_output (qse_htrd_t* htrd, qse_htre_t* res)
}
}
if ((proxy->flags & PROXY_UPGRADE_REQUESTED) && qse_htre_getscodeval(res) == 101)
{
if (qse_mbs_cat (proxy->res, QSE_MT("Connection: Upgrade\r\n")) == (qse_size_t)-1)
{
httpd->errnum = QSE_HTTPD_ENOMEM;
return -1;
}
}
else
{
if (qse_mbs_cat (proxy->res, (keepalive? QSE_MT("Connection: keep-alive\r\n"): QSE_MT("Connection: close\r\n"))) == (qse_size_t)-1)
{
httpd->errnum = QSE_HTTPD_ENOMEM;
return -1;
}
}
if (qse_htre_walkheaders (res, proxy_capture_peer_header, proxy) <= -1) return -1;
@ -778,7 +789,6 @@ static int proxy_htrd_peek_peer_output (qse_htrd_t* htrd, qse_htre_t* res)
/* arrange to store further contents received to proxy->res */
qse_htre_setconcb (res, proxy_snatch_peer_output, xtn->task);
}
}
if (proxy->flags & PROXY_UPGRADE_REQUESTED)
{
@ -810,6 +820,8 @@ static int proxy_htrd_peek_peer_output (qse_htrd_t* htrd, qse_htre_t* res)
/*task->trigger.v[0].mask &= ~QSE_HTTPD_TASK_TRIGGER_WRITE;*/ /* peer */
proxy->task->trigger.cmask |= QSE_HTTPD_TASK_TRIGGER_READ; /* client-side */
}
}
proxy->res_pending = QSE_MBS_LEN(proxy->res) - proxy->res_consumed;
return 0;