add support for OPTIONS http method

This commit is contained in:
2022-08-11 08:04:40 +02:00
parent f651df6e1f
commit ceb5336ca1
7 changed files with 41 additions and 10 deletions

View File

@@ -828,8 +828,8 @@ void Request::ModifyStatusForRedirect()
void Request::SendAnswer()
// may rename to something like PrepareAndSendAnswer()?
void Request::PrepareAndSendAnswer()
{
output_8bit.clear();
compressed_output.clear();
@@ -845,9 +845,7 @@ void Request::SendAnswer()
}
}
// may use CanSendContent() method?
// what about method HEAD?
if( !redirect_to.empty() || !x_sendfile.empty() )
if( !redirect_to.empty() || !x_sendfile.empty() || method == Request::options )
{
Send8bitOutput(output_8bit); // send empty content
return;
@@ -1787,7 +1785,7 @@ void Request::SendHeaders()
{
if( i->second->is_wstr() )
{
pt::wide_to_utf8(i->first, aheader_name);
pt::wide_to_utf8(i->first, aheader_name);
pt::wide_to_utf8(*i->second->get_wstr(), aheader_value);
FCGX_PutS(aheader_name.c_str(), fcgi_request.out);
@@ -1905,7 +1903,7 @@ bool Request::CanSendContent()
return false;
}
if( method == Request::head )
if( method == Request::head || method == Request::options )
{
return false;
}
@@ -1933,7 +1931,7 @@ void Request::LogRequestTime()
void Request::FinishRequest()
{
modify_status_code_if_needed(); // will be removed
SendAnswer();
PrepareAndSendAnswer();
RequestEnds();
LogRequestTime();