]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/jaeger-client-cpp/src/jaegertracing/net/http/Request.cpp
2 * Copyright (c) 2017-2018 Uber Technologies, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "jaegertracing/net/http/Request.h"
18 #include "jaegertracing/net/http/SocketReader.h"
22 namespace jaegertracing
{
26 Request
Request::read(Socket
& socket
)
28 std::string response
= SocketReader::read(socket
);
29 std::istringstream
responseStream(response
);
30 return Request::parse(responseStream
);
33 Request
Request::parse(std::istream
& in
)
35 const std::regex
requestLinePattern(
36 "([A-Z]+) ([^ ]+) HTTP/([0-9]\\.[0-9])$");
39 if (!readLineCRLF(in
, line
) ||
40 !std::regex_match(line
, match
, requestLinePattern
) ||
42 throw ParseError::make("request line", line
);
46 request
._method
= parseMethod(match
[1]);
47 request
._target
= match
[2];
48 request
._version
= match
[3];
50 readHeaders(in
, request
._headers
);
51 request
._body
= std::string(std::istreambuf_iterator
<char>(in
),
52 std::istreambuf_iterator
<char>{});
59 } // namespace jaegertracing