XRootD
Loading...
Searching...
No Matches
XrdClHttpHeaderBuilder.hh
Go to the documentation of this file.
1#ifndef XRDCLHTTP_HEADERBUILDER_HH
2#define XRDCLHTTP_HEADERBUILDER_HH
3
4#include <string>
5#include <string_view>
6#include <utility>
7#include <vector>
8
9namespace XrdClHttp {
10
11// Builds the headers a client asks a request to carry. The request is
12// described by the HttpHeaders environment setting, which xrdcp fills in from
13// its --header option. These functions are the only place it is interpreted.
14namespace HeaderBuilder {
15
16using HeaderList = std::vector<std::pair<std::string, std::string>>;
17
18// Returns true if the named header must not be injected by the client. A
19// forbidden name stays forbidden under the TransferHeader prefix, which aims a
20// header at the far server of a third party copy.
21[[nodiscard]] bool IsForbiddenHeader(std::string_view name);
22
23// Returns true if the two strings are the same, ignoring case.
24[[nodiscard]] bool CompareIgnoreCase(std::string_view lhs, std::string_view rhs);
25
26// Build into `headers` the headers `spec` asks for, replacing its contents.
27// `spec` is a newline separated list of "<name>: <value>" entries; callers pass
28// the user's input through verbatim.
29//
30// Returns false if any entry is malformed or names a forbidden header, in which
31// case the request must not be sent -- a dropped header changes what the
32// request asks for. A rejected specification leaves `headers` empty.
33[[nodiscard]] bool Build(std::string_view spec, HeaderList &headers);
34
35// Append to `headers` each entry of `extra` whose name `headers` does not
36// already carry. A request keeps the headers it built for itself: a requested
37// Range, Depth or Want-Digest would corrupt it.
38void AppendMissing(const HeaderList &extra, HeaderList &headers);
39
40} // namespace HeaderBuilder
41
42} // namespace XrdClHttp
43
44#endif // XRDCLHTTP_HEADERBUILDER_HH
int extra
Definition XrdAccTest.cc:63
bool IsForbiddenHeader(const std::string_view name)
bool CompareIgnoreCase(const std::string_view lhs, const std::string_view rhs)
void AppendMissing(const HeaderList &extra, HeaderList &headers)
bool Build(const std::string_view spec, HeaderList &headers)
std::vector< std::pair< std::string, std::string > > HeaderList