| 245 | } |
| 246 | |
| 247 | void THttpParser::ParseHeaderLine() { |
| 248 | if (!!HeaderLine_) { |
| 249 | if (CollectHeaders_) { |
| 250 | THttpInputHeader hdr(HeaderLine_); |
| 251 | |
| 252 | Headers_.AddHeader(hdr); |
| 253 | |
| 254 | ApplyHeaderLine(hdr.Name(), hdr.Value()); |
| 255 | } else { |
| 256 | //some dirty optimization (avoid reallocation new strings) |
| 257 | size_t pos = HeaderLine_.find(':'); |
| 258 | |
| 259 | if (pos == TString::npos) { |
| 260 | ythrow THttpParseException() << "can not parse http header(" << HeaderLine_.Quote() << ")"; |
| 261 | } |
| 262 | |
| 263 | TStringBuf name(StripString(TStringBuf(HeaderLine_.begin(), HeaderLine_.begin() + pos))); |
| 264 | TStringBuf val(StripString(TStringBuf(HeaderLine_.begin() + pos + 1, HeaderLine_.end()))); |
| 265 | ApplyHeaderLine(name, val); |
| 266 | } |
| 267 | HeaderLine_.remove(0); |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | void THttpParser::OnEof() { |
| 272 | if (Parser_ == &THttpParser::ContentParser && !HasContentLength_ && !ChunkInputState_) { |