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

refine the http request reader.

This commit is contained in:
winlin 2015-03-04 18:20:15 +08:00
parent 3e394a5f06
commit 025b707330
6 changed files with 289 additions and 133 deletions

View file

@ -35,6 +35,7 @@ using namespace std;
#include <srs_app_st_socket.hpp>
#include <srs_kernel_utility.hpp>
#include <srs_app_utility.hpp>
#include <srs_core_autofree.hpp>
// when error, http client sleep for a while and retry.
#define SRS_HTTP_CLIENT_SLEEP_US (int64_t)(3*1000*1000LL)
@ -103,18 +104,18 @@ int SrsHttpClient::post(SrsHttpUri* uri, string req, int& status_code, string& r
}
srs_assert(msg);
srs_assert(msg->is_complete());
// always free it in this scope.
SrsAutoFree(SrsHttpMessage, msg);
status_code = (int)msg->status_code();
// get response body.
if (msg->body_size() > 0) {
res = msg->body();
if ((ret = msg->body_read_all(res)) != ERROR_SUCCESS) {
return ret;
}
srs_info("parse http post response success.");
srs_freep(msg);
return ret;
}