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

support http api json, to PUT/POST, to 0.9.103

This commit is contained in:
winlin 2014-05-18 16:15:35 +08:00
parent b60e8418c6
commit d6355efe22
11 changed files with 358 additions and 43 deletions

View file

@ -134,6 +134,17 @@ int SrsHttpHandler::do_process_request(SrsSocket* /*skt*/, SrsHttpMessage* /*req
return ret;
}
int SrsHttpHandler::response_error(SrsSocket* skt, SrsHttpMessage* req, int code, string desc)
{
std::stringstream ss;
ss << JOBJECT_START
<< JFIELD_ERROR(code) << JFIELD_CONT
<< JFIELD_STR("desc", desc)
<< JOBJECT_END;
return res_json(skt, req, ss.str());
}
int SrsHttpHandler::best_match(const char* path, int length, SrsHttpHandlerMatch** ppmatch)
{
int ret = ERROR_SUCCESS;
@ -566,6 +577,26 @@ u_int8_t SrsHttpMessage::method()
return (u_int8_t)_header.method;
}
bool SrsHttpMessage::is_http_get()
{
return _header.method == HTTP_GET;
}
bool SrsHttpMessage::is_http_put()
{
return _header.method == HTTP_PUT;
}
bool SrsHttpMessage::is_http_post()
{
return _header.method == HTTP_POST;
}
bool SrsHttpMessage::is_http_delete()
{
return _header.method == HTTP_DELETE;
}
string SrsHttpMessage::url()
{
return _uri->get_url();
@ -592,6 +623,15 @@ string SrsHttpMessage::body()
return b;
}
char* SrsHttpMessage::body_raw()
{
if (_body && !_body->empty()) {
return _body->bytes();
}
return NULL;
}
int64_t SrsHttpMessage::body_size()
{
return (int64_t)_body->size();