| 326 | } |
| 327 | |
| 328 | int HttpMessage::OnMessageComplete() { |
| 329 | if (_vmsgbuilder) { |
| 330 | if (_vbodylen > (size_t)FLAGS_http_verbose_max_body_length) { |
| 331 | *_vmsgbuilder << "\n<skipped " << _vbodylen |
| 332 | - (size_t)FLAGS_http_verbose_max_body_length << " bytes>"; |
| 333 | } |
| 334 | LOG(INFO) << '\n' << _vmsgbuilder->buf(); |
| 335 | _vmsgbuilder.reset(NULL); |
| 336 | } |
| 337 | _cur_header.clear(); |
| 338 | _cur_value = NULL; |
| 339 | if (!_read_body_progressively) { |
| 340 | // Normal read. |
| 341 | _stage = HTTP_ON_MESSAGE_COMPLETE; |
| 342 | return 0; |
| 343 | } |
| 344 | // Progressive read. |
| 345 | std::unique_lock<butil::Mutex> mu(_body_mutex); |
| 346 | _stage = HTTP_ON_MESSAGE_COMPLETE; |
| 347 | if (_body_reader != NULL) { |
| 348 | // Solve the case: SetBodyReader quit at ntry=MAX_TRY with non-empty |
| 349 | // _body and the remaining _body is just the last part. |
| 350 | // Make sure _body is emptied. |
| 351 | if (UnlockAndFlushToBodyReader(mu) != 0) { |
| 352 | return -1; |
| 353 | } |
| 354 | mu.lock(); |
| 355 | ProgressiveReader* r = _body_reader; |
| 356 | _body_reader = NULL; |
| 357 | mu.unlock(); |
| 358 | r->OnEndOfMessage(butil::Status()); |
| 359 | } |
| 360 | return 0; |
| 361 | } |
| 362 | |
| 363 | class FailAllRead : public ProgressiveReader { |
| 364 | public: |
no test coverage detected