17#include <cppunit/TestAssert.h>
66 SBuf url(
"http://foo:90/bar");
67 const auto mx = MasterXaction::MakePortless<XactionInitiator::initHtcp>();
70 CPPUNIT_ASSERT(aRequest !=
nullptr);
71 CPPUNIT_ASSERT_EQUAL(expected_port, *aRequest->
url.
port());
74 CPPUNIT_ASSERT_EQUAL(
SBuf(
"/bar"), aRequest->
url.
path());
78 url =
"http://foo:90/bar";
81 CPPUNIT_ASSERT(aRequest !=
nullptr);
82 CPPUNIT_ASSERT_EQUAL(expected_port, *aRequest->
url.
port());
85 CPPUNIT_ASSERT_EQUAL(
SBuf(
"/bar"), aRequest->
url.
path());
89 url =
"http://foo/bar";
92 CPPUNIT_ASSERT(aRequest !=
nullptr);
93 CPPUNIT_ASSERT_EQUAL(expected_port, *aRequest->
url.
port());
96 CPPUNIT_ASSERT_EQUAL(
SBuf(
"/bar"), aRequest->
url.
path());
103 CPPUNIT_ASSERT_EQUAL(nullRequest, aRequest);
109 CPPUNIT_ASSERT(aRequest !=
nullptr);
110 CPPUNIT_ASSERT_EQUAL(expected_port, *aRequest->
url.
port());
113 CPPUNIT_ASSERT_EQUAL(
SBuf(), aRequest->
url.
path());
128 SBuf url(
"http://[2000:800::45]/foo");
129 const auto mx = MasterXaction::MakePortless<XactionInitiator::initHtcp>();
132 CPPUNIT_ASSERT_EQUAL(expected_port, *aRequest->
url.
port());
135 CPPUNIT_ASSERT_EQUAL(
SBuf(
"/foo"), aRequest->
url.
path());
139 url =
"http://[2000:800::45]:90/foo";
142 CPPUNIT_ASSERT_EQUAL(expected_port, *aRequest->
url.
port());
145 CPPUNIT_ASSERT_EQUAL(
SBuf(
"/foo"), aRequest->
url.
path());
149 url =
"http://2000:800::45/foo";
152 CPPUNIT_ASSERT_EQUAL(expected_port, *aRequest->
url.
port());
155 CPPUNIT_ASSERT_EQUAL(
SBuf(
"/foo"), aRequest->
url.
path());
163 const auto mx = MasterXaction::MakePortless<XactionInitiator::initHtcp>();
170 input.
append(
"GET / HTTP/1.1\n\n", 16);
177 input.
append(
"GET / HTTP/1.1\n\n", 18);
185 input.
append(
". / HTTP/1.1\n\n", 14);
192 input.
append(
"OPTIONS * HTTP/1.1\n\n", 20);
void error(char *format,...)
static void Init()
initializes down-cased protocol scheme names array
AnyP::UriScheme const & getScheme() const
void port(const Port p)
reset authority port subcomponent
void host(const char *src)
bool sanityCheckStartLine(const char *buf, const size_t hdr_len, Http::StatusCode *error) override
static HttpRequest * FromUrl(const SBuf &url, const MasterXaction::Pointer &, const HttpRequestMethod &method=Http::METHOD_GET)
AnyP::Uri url
the request URI
void append(const char *c, int sz) override
void init(mb_size_t szInit, mb_size_t szMax)
char * content()
start of the added data
mb_size_t contentSize() const
available data size
customizes our test setup
bool doSanityCheckStartLine(const char *b, const size_t h, Http::StatusCode *e)
PrivateHttpRequest(const MasterXaction::Pointer &mx)
CPPUNIT_TEST_SUITE(TestHttpRequest)
CPPUNIT_TEST(testCreateFromUrl)
void testSanityCheckStartLine()
CPPUNIT_TEST(testIPv6HostColonBug)
void testIPv6HostColonBug()
CPPUNIT_TEST(testSanityCheckStartLine)
implements test program's main() function while enabling customization
int run(int argc, char *argv[])
uint16_t KnownPort
validated/supported port number; these values are never zero
@ scInvalidHeader
Squid header parsing error.
CPPUNIT_TEST_SUITE_REGISTRATION(TestHttpRequest)