-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmhd_http_request.cc
47 lines (36 loc) · 1.23 KB
/
mhd_http_request.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright 2019 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cups_proxy/mhd_http_request.h"
#include <algorithm>
#include <utility>
namespace cups_proxy {
MHDHttpRequest::MHDHttpRequest() : chunked_(false) {}
void MHDHttpRequest::SetStatusLine(base::StringPiece method,
base::StringPiece url,
base::StringPiece version) {
method_ = method.as_string();
url_ = url.as_string();
version_ = version.as_string();
}
void MHDHttpRequest::AddHeader(base::StringPiece key, base::StringPiece value) {
// strip 100-continue message from ipp request
if (key == "Expect" && value == "100-continue") {
return;
}
// strip chunked header from ipp request
if (key == "Transfer-Encoding" && value == "chunked") {
chunked_ = true;
return;
}
headers_[key.as_string()] = value.as_string();
}
void MHDHttpRequest::Finalize() {
if (chunked_) {
AddHeader("Content-Length", std::to_string(body_.size()));
}
}
void MHDHttpRequest::PushToBody(base::StringPiece data) {
body_.insert(body_.end(), data.begin(), data.end());
}
} // namespace cups_proxy