| 515 | } |
| 516 | |
| 517 | inline void Write(const void* buf, size_t len) { |
| 518 | if (Finished_) { |
| 519 | ythrow THttpException() << "can not write to finished stream"; |
| 520 | } |
| 521 | |
| 522 | if (State_ == HeadersSent) { |
| 523 | Output_->Write(buf, len); |
| 524 | |
| 525 | return; |
| 526 | } |
| 527 | |
| 528 | const char* b = (const char*)buf; |
| 529 | const char* e = b + len; |
| 530 | const char* c = b; |
| 531 | |
| 532 | while (c != e) { |
| 533 | if (*c == '\n') { |
| 534 | Line_.append(b, c); |
| 535 | |
| 536 | if (!Line_.empty() && Line_.back() == '\r') { |
| 537 | Line_.pop_back(); |
| 538 | } |
| 539 | |
| 540 | b = c + 1; |
| 541 | |
| 542 | Process(Line_); |
| 543 | |
| 544 | if (State_ == HeadersSent) { |
| 545 | Output_->Write(b, e - b); |
| 546 | |
| 547 | return; |
| 548 | } |
| 549 | |
| 550 | Line_.clear(); |
| 551 | } |
| 552 | |
| 553 | ++c; |
| 554 | } |
| 555 | |
| 556 | if (b != c) { |
| 557 | Line_.append(b, c); |
| 558 | } |
| 559 | } |
| 560 | |
| 561 | inline void Flush() { |
| 562 | TFlush f; |
no test coverage detected