MCPcopy Create free account
hub / github.com/aria2/aria2 / testCreateRequest

Method testCreateRequest

test/HttpRequestTest.cc:131–321  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131void HttpRequestTest::testCreateRequest()
132{
133 auto request = std::make_shared<Request>();
134 request->supportsPersistentConnection(true);
135 request->setUri("http://localhost:8080/archives/aria2-1.0.0.tar.bz2");
136
137 auto p = std::make_shared<Piece>(0, 1_k);
138 auto segment = std::make_shared<PiecedSegment>(1_k, p);
139 auto fileEntry = std::make_shared<FileEntry>("file", 10_m, 0);
140
141 HttpRequest httpRequest;
142 httpRequest.disableContentEncoding();
143 httpRequest.setRequest(request);
144 httpRequest.setSegment(segment);
145 httpRequest.setFileEntry(fileEntry);
146 httpRequest.setAuthConfigFactory(authConfigFactory_.get());
147 httpRequest.setOption(option_.get());
148 httpRequest.setNoWantDigest(true);
149
150 // remove "Connection: close" and add end byte range
151 request->setPipeliningHint(true);
152
153 std::string expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
154 "User-Agent: aria2\r\n"
155 "Accept: */*\r\n"
156 "Host: localhost:8080\r\n"
157 "Pragma: no-cache\r\n"
158 "Cache-Control: no-cache\r\n"
159 "Range: bytes=0-1023\r\n"
160 "\r\n";
161
162 CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
163
164 request->setPipeliningHint(false);
165
166 expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
167 "User-Agent: aria2\r\n"
168 "Accept: */*\r\n"
169 "Host: localhost:8080\r\n"
170 "Pragma: no-cache\r\n"
171 "Cache-Control: no-cache\r\n"
172 "Connection: close\r\n"
173 "\r\n";
174
175 CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
176
177 p.reset(new Piece(1, 1_m));
178 segment.reset(new PiecedSegment(1_m, p));
179 httpRequest.setSegment(segment);
180
181 expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n"
182 "User-Agent: aria2\r\n"
183 "Accept: */*\r\n"
184 "Host: localhost:8080\r\n"
185 "Pragma: no-cache\r\n"
186 "Cache-Control: no-cache\r\n"
187 "Connection: close\r\n"
188 "Range: bytes=1048576-\r\n"

Callers

nothing calls this directly

Calls 15

setUriMethod · 0.80
setSegmentMethod · 0.80
setNoWantDigestMethod · 0.80
setPipeliningHintMethod · 0.80
redirectUriMethod · 0.80
setKeepAliveHintMethod · 0.80
resetUriMethod · 0.80
activateBasicCredMethod · 0.80
setRequestMethod · 0.45
setFileEntryMethod · 0.45

Tested by

no test coverage detected