17 #include <sys/types.h> 25 msg.
getHeaders().
add(
"Cookie",
"id=1256679245; data=0:1234567");
34 msg.
getHeaders().
add(
"Cookie",
" id=1256679245 ; data=0:1234567 ;");
50 "Cookie",
"id=1256679245; data=0:1234567; same=Always; Name");
52 "Cookie",
"id2=1256679245; data2=0:1234567; same=Always; ");
63 string url =
"/test?seq=123456&userid=1256679245&dup=1&dup=2&helloWorld" 64 "&second=was+it+clear+%28already%29%3F";
84 std::vector<std::vector<std::string>> input = {
86 {
"key_and_equal_but_no_value",
"=",
""},
88 {
"key_and_value",
"=",
"value"},
89 {
"key_and_value_2",
"=",
"value2"},
90 {
"key_and_value_3",
"=",
"value3"}
93 for (
int i = 0;
i < (1 << input.size()); ++
i) {
94 std::vector<std::vector<std::string>>
sub;
95 for (
size_t j = 0; j < input.size(); ++j) {
97 sub.push_back(input[j]);
101 sort(sub.begin(), sub.end());
105 for (
const auto&
val: sub) {
116 for (
const auto&
val: sub) {
124 }
while (next_permutation(sub.begin(), sub.end()));
132 hdrs.
add(
"Jojo",
"1");
133 hdrs.
add(
"Binky",
"2");
134 hdrs.
add(
"jOJo",
"3");
135 hdrs.
add(
"bINKy",
"4");
146 hdrs.
add(
"Jojo",
"1");
147 hdrs.
add(
"Binky",
"2");
148 hdrs.
add(
"jOJo",
"3");
149 hdrs.
add(
"bINKy",
"4");
160 hdrs.
set(
"Jojo",
"1");
164 hdrs.
add(
"jojo",
"2");
165 hdrs.
add(
"jojo",
"3");
166 hdrs.
add(
"bar",
"4");
170 hdrs.
set(
"joJO",
"5");
181 headers.
add(
"Combine",
"first value");
184 headers.
add(
"Combine",
"second value");
187 headers.
add(
"Combine",
"third value");
189 "first value, second value, third value");
360 const string& expectedPath,
361 const string& expectedQuery) {
379 const char foo[] =
"name:value";
384 headers.
add(name, str);
391 hdrs.
add({{
"name",
"value"}});
393 hdrs.
add({{
"a",
"b"},
405 const char*
foo =
"name:value";
415 const string& queryParam,
416 const string& expectedUrl,
417 const string& expectedQuery) {
420 bool expectedChange = (url != expectedUrl);
431 "http://localhost:80/foo?param1=a#qqq",
436 "http://localhost/foo?param1=a¶m2=b#qqq",
437 "param1=a¶m2=b");
441 "localhost:80/foo?param1=a#qqq",
451 const string& queryParam,
452 const string& paramValue,
453 const string& expectedUrl,
454 const string& expectedQuery) {
457 bool expectedChange = (url != expectedUrl);
469 "http://localhost:80/foo?param1=a¶m2=true#qqq",
470 "param1=a¶m2=true");
475 "http://localhost/foo?param1=a¶m2=b¶m3=true#qqq",
476 "param1=a¶m2=b¶m3=true");
481 "localhost:80/foo?param1=a¶m2=b¶m3=c#qqq",
482 "param1=a¶m2=b¶m3=c");
487 "localhost:80/foo?param2=b#qqq",
502 TEST(HttpMessage, TestProtocolStringHTTPVersion) {
509 TEST(HttpMessage, TestProtocolStringAdvancedProtocol) {
#define EXPECT_ANY_THROW(statement)
void setWantsKeepalive(bool wantsKeepaliveVal)
const std::string & getPath() const
void testPathAndQuery(const string &url, const string &expectedPath, const string &expectedQuery)
#define EXPECT_DEATH_NO_CORE(token, regex)
#define EXPECT_EQ(val1, val2)
TEST(HTTPMessage, TestParseCookiesSimple)
void testRemoveQueryParam(const string &url, const string &queryParam, const string &expectedUrl, const string &expectedQuery)
void setDstAddress(const folly::SocketAddress &addr, std::string addressStr=empty_string, std::string portStr=empty_string)
Range split_step(value_type delimiter)
const HTTPHeaders & getStrippedPerHopHeaders() const
void setAdvancedProtocolString(const std::string &protocol)
bool computeKeepalive() const
const std::string & getQueryString() const
const folly::StringPiece getCookie(const std::string &name) const
const std::string & getQueryParam(const std::string &name) const
bool checkForHeaderToken(const HTTPHeaderCode headerCode, char const *token, bool caseSensitive) const
constexpr auto empty(C const &c) -> decltype(c.empty())
void stripPerHopHeaders()
int getIntQueryParam(const std::string &name) const
bool setQueryParam(const std::string &name, const std::string &value)
HTTPHeaders & getHeaders()
void setMethod(HTTPMethod method)
std::string getDecodedQueryParam(const std::string &name) const
#define EXPECT_TRUE(condition)
bool removeQueryParam(const std::string &name)
bool hasQueryParam(const std::string &name) const
const std::string & getMethodString() const
void setHTTPVersion(uint8_t major, uint8_t minor)
#define EXPECT_FALSE(condition)
folly::Optional< HTTPMethod > getMethod() const
const std::string & getProtocolString() const
const std::string & getURL() const
void testSetQueryParam(const string &url, const string &queryParam, const string ¶mValue, const string &expectedUrl, const string &expectedQuery)
bool wantsKeepalive() const
constexpr detail::First first