mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Fix HTTP CORS bug when sending response for OPTIONS. 3.0.72
This commit is contained in:
parent
ec0fb82c0e
commit
dc1afc142f
8 changed files with 345 additions and 21 deletions
|
@ -264,7 +264,7 @@ SrsHttpMessage::SrsHttpMessage(ISrsReader* reader, SrsFastStream* buffer) : ISrs
|
|||
|
||||
_method = 0;
|
||||
_status = 0;
|
||||
_content_length = 0;
|
||||
_content_length = -1;
|
||||
_keep_alive = true;
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,9 @@ void SrsHttpMessage::set_basic(uint8_t method, uint16_t status, int64_t content_
|
|||
{
|
||||
_method = method;
|
||||
_status = status;
|
||||
_content_length = content_length;
|
||||
if (_content_length == -1) {
|
||||
_content_length = content_length;
|
||||
}
|
||||
}
|
||||
|
||||
void SrsHttpMessage::set_header(SrsHttpHeader* header, bool keep_alive)
|
||||
|
@ -288,6 +290,12 @@ void SrsHttpMessage::set_header(SrsHttpHeader* header, bool keep_alive)
|
|||
|
||||
// whether chunked.
|
||||
chunked = (header->get("Transfer-Encoding") == "chunked");
|
||||
|
||||
// Update the content-length in header.
|
||||
string clv = header->get("Content-Length");
|
||||
if (!clv.empty()) {
|
||||
_content_length = ::atoll(clv.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
srs_error_t SrsHttpMessage::set_url(string url, bool allow_jsonp)
|
||||
|
|
|
@ -126,12 +126,14 @@ private:
|
|||
// The method in QueryString will override the HTTP method.
|
||||
std::string jsonp_method;
|
||||
public:
|
||||
SrsHttpMessage(ISrsReader* reader, SrsFastStream* buffer);
|
||||
SrsHttpMessage(ISrsReader* reader = NULL, SrsFastStream* buffer = NULL);
|
||||
virtual ~SrsHttpMessage();
|
||||
public:
|
||||
// Set the basic information for HTTP request.
|
||||
// @remark User must call set_basic before set_header, because the content_length will be overwrite by header.
|
||||
virtual void set_basic(uint8_t method, uint16_t status, int64_t content_length);
|
||||
// Set HTTP header and whether the request require keep alive.
|
||||
// @remark User must call set_header before set_url, because the Host in header is used for url.
|
||||
virtual void set_header(SrsHttpHeader* header, bool keep_alive);
|
||||
// set the original messages, then update the message.
|
||||
virtual srs_error_t set_url(std::string url, bool allow_jsonp);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue