Fix llhttp_get_error_pos usage
It returns NULL if return value is HPE_OK.
This commit is contained in:
parent
a3a034813b
commit
0288093caf
|
@ -203,8 +203,11 @@ int Http1Session::submit_request() {
|
|||
int Http1Session::on_read(const uint8_t *data, size_t len) {
|
||||
auto htperr =
|
||||
llhttp_execute(&htp_, reinterpret_cast<const char *>(data), len);
|
||||
auto nread = static_cast<size_t>(
|
||||
reinterpret_cast<const uint8_t *>(llhttp_get_error_pos(&htp_)) - data);
|
||||
auto nread = htperr == HPE_OK
|
||||
? len
|
||||
: static_cast<size_t>(reinterpret_cast<const uint8_t *>(
|
||||
llhttp_get_error_pos(&htp_)) -
|
||||
data);
|
||||
|
||||
if (client_->worker->config->verbose) {
|
||||
std::cout.write(reinterpret_cast<const char *>(data), nread);
|
||||
|
|
|
@ -1035,8 +1035,10 @@ int HttpClient::on_upgrade_read(const uint8_t *data, size_t len) {
|
|||
|
||||
auto htperr =
|
||||
llhttp_execute(htp.get(), reinterpret_cast<const char *>(data), len);
|
||||
auto nread = static_cast<size_t>(
|
||||
reinterpret_cast<const uint8_t *>(llhttp_get_error_pos(htp.get())) -
|
||||
auto nread = htperr == HPE_OK
|
||||
? len
|
||||
: static_cast<size_t>(reinterpret_cast<const uint8_t *>(
|
||||
llhttp_get_error_pos(htp.get())) -
|
||||
data);
|
||||
|
||||
if (config.verbose) {
|
||||
|
|
|
@ -1402,8 +1402,11 @@ int HttpDownstreamConnection::process_input(const uint8_t *data,
|
|||
|
||||
auto htperr = llhttp_execute(&response_htp_,
|
||||
reinterpret_cast<const char *>(data), datalen);
|
||||
auto nproc = static_cast<size_t>(
|
||||
reinterpret_cast<const uint8_t *>(llhttp_get_error_pos(&response_htp_)) -
|
||||
auto nproc =
|
||||
htperr == HPE_OK
|
||||
? datalen
|
||||
: static_cast<size_t>(reinterpret_cast<const uint8_t *>(
|
||||
llhttp_get_error_pos(&response_htp_)) -
|
||||
data);
|
||||
|
||||
if (htperr != HPE_OK &&
|
||||
|
|
|
@ -629,7 +629,10 @@ int HttpsUpstream::on_read() {
|
|||
auto htperr = llhttp_execute(&htp_, reinterpret_cast<const char *>(rb->pos()),
|
||||
rb->rleft());
|
||||
|
||||
auto nread = reinterpret_cast<const uint8_t *>(llhttp_get_error_pos(&htp_)) -
|
||||
auto nread =
|
||||
htperr == HPE_OK
|
||||
? rb->rleft()
|
||||
: reinterpret_cast<const uint8_t *>(llhttp_get_error_pos(&htp_)) -
|
||||
rb->pos();
|
||||
rb->drain(nread);
|
||||
rlimit->startw();
|
||||
|
|
Loading…
Reference in New Issue