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

Method testCreateRequest_ftp

test/HttpRequestTest.cc:323–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

321}
322
323void HttpRequestTest::testCreateRequest_ftp()
324{
325 option_->put(PREF_FTP_USER, "aria2user");
326 option_->put(PREF_FTP_PASSWD, "aria2passwd");
327
328 auto request = std::make_shared<Request>();
329 request->setUri("ftp://localhost:8080/archives/aria2-1.0.0.tar.bz2");
330
331 auto proxyRequest = std::make_shared<Request>();
332 CPPUNIT_ASSERT(proxyRequest->setUri("http://localhost:9000"));
333
334 HttpRequest httpRequest;
335 auto p = std::make_shared<Piece>(0, 1_m);
336 auto segment = std::make_shared<PiecedSegment>(1_m, p);
337 auto fileEntry = std::make_shared<FileEntry>("file", 10_m, 0);
338
339 httpRequest.disableContentEncoding();
340 httpRequest.setRequest(request);
341 httpRequest.setSegment(segment);
342 httpRequest.setFileEntry(fileEntry);
343 httpRequest.setAuthConfigFactory(authConfigFactory_.get());
344 httpRequest.setOption(option_.get());
345 httpRequest.setProxyRequest(proxyRequest);
346 httpRequest.setNoWantDigest(true);
347
348 std::string expectedText =
349 "GET ftp://aria2user@localhost:8080/archives/aria2-1.0.0.tar.bz2"
350 " HTTP/1.1\r\n"
351 "User-Agent: aria2\r\n"
352 "Accept: */*\r\n"
353 "Host: localhost:8080\r\n"
354 "Pragma: no-cache\r\n"
355 "Cache-Control: no-cache\r\n"
356 "Connection: close\r\n"
357 "Authorization: Basic YXJpYTJ1c2VyOmFyaWEycGFzc3dk\r\n"
358 "\r\n";
359
360 CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
361
362 // test proxy authorization
363 CPPUNIT_ASSERT(proxyRequest->setUri(
364 "http://aria2proxyuser:aria2proxypasswd@localhost:9000"));
365
366 expectedText =
367 "GET ftp://aria2user@localhost:8080/archives/aria2-1.0.0.tar.bz2"
368 " HTTP/1.1\r\n"
369 "User-Agent: aria2\r\n"
370 "Accept: */*\r\n"
371 "Host: localhost:8080\r\n"
372 "Pragma: no-cache\r\n"
373 "Cache-Control: no-cache\r\n"
374 "Connection: close\r\n"
375 "Proxy-Authorization: Basic "
376 "YXJpYTJwcm94eXVzZXI6YXJpYTJwcm94eXBhc3N3ZA==\r\n"
377 "Authorization: Basic YXJpYTJ1c2VyOmFyaWEycGFzc3dk\r\n"
378 "\r\n";
379
380 CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());

Callers

nothing calls this directly

Calls 12

setUriMethod · 0.80
setSegmentMethod · 0.80
setNoWantDigestMethod · 0.80
putMethod · 0.45
setRequestMethod · 0.45
setFileEntryMethod · 0.45
setAuthConfigFactoryMethod · 0.45
getMethod · 0.45
setOptionMethod · 0.45
setProxyRequestMethod · 0.45
createRequestMethod · 0.45

Tested by

no test coverage detected