1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #1657, fix the jsonp bug

This commit is contained in:
winlin 2020-11-05 17:57:22 +08:00
parent fc21b31714
commit d67b050935
8 changed files with 60 additions and 53 deletions

View file

@ -281,7 +281,7 @@ srs_error_t SrsHttpClient::initialize(string schema, string h, int p, srs_utime_
srs_freep(parser);
parser = new SrsHttpParser();
if ((err = parser->initialize(HTTP_RESPONSE, false)) != srs_success) {
if ((err = parser->initialize(HTTP_RESPONSE)) != srs_success) {
return srs_error_wrap(err, "http: init parser");
}

View file

@ -52,11 +52,11 @@ SrsHttpParser::~SrsHttpParser()
srs_freep(header);
}
srs_error_t SrsHttpParser::initialize(enum http_parser_type type, bool allow_jsonp)
srs_error_t SrsHttpParser::initialize(enum http_parser_type type)
{
srs_error_t err = srs_success;
jsonp = allow_jsonp;
jsonp = false;
type_ = type;
// Initialize the parser, however it's not necessary.
@ -75,6 +75,11 @@ srs_error_t SrsHttpParser::initialize(enum http_parser_type type, bool allow_jso
return err;
}
void SrsHttpParser::set_jsonp(bool allow_jsonp)
{
jsonp = allow_jsonp;
}
srs_error_t SrsHttpParser::parse_message(ISrsReader* reader, ISrsHttpMessage** ppmsg)
{
srs_error_t err = srs_success;

View file

@ -67,8 +67,9 @@ public:
public:
// initialize the http parser with specified type,
// one parser can only parse request or response messages.
// @param allow_jsonp whether allow jsonp parser, which indicates the method in query string.
virtual srs_error_t initialize(enum http_parser_type type, bool allow_jsonp = false);
virtual srs_error_t initialize(enum http_parser_type type);
// Whether allow jsonp parser, which indicates the method in query string.
virtual void set_jsonp(bool allow_jsonp);
// always parse a http message,
// that is, the *ppmsg always NOT-NULL when return success.
// or error and *ppmsg must be NULL.