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

Method testCreateProxyRequest

test/HttpRequestTest.cc:635–697  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

633}
634
635void HttpRequestTest::testCreateProxyRequest()
636{
637 auto request = std::make_shared<Request>();
638 request->setUri("http://localhost/archives/aria2-1.0.0.tar.bz2");
639 auto p = std::make_shared<Piece>(0, 1_m);
640 auto segment = std::make_shared<PiecedSegment>(1_m, p);
641
642 auto proxyRequest = std::make_shared<Request>();
643 CPPUNIT_ASSERT(proxyRequest->setUri("http://localhost:9000"));
644
645 HttpRequest httpRequest;
646
647 httpRequest.setRequest(request);
648 httpRequest.setSegment(segment);
649 httpRequest.setProxyRequest(proxyRequest);
650
651 request->supportsPersistentConnection(true);
652
653 std::string expectedText = "CONNECT localhost:80 HTTP/1.1\r\n"
654 "User-Agent: aria2\r\n"
655 "Host: localhost:80\r\n"
656 //"Proxy-Connection: close\r\n"
657 "\r\n";
658
659 CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createProxyRequest());
660
661 // adds Keep-Alive header.
662 request->setKeepAliveHint(true);
663
664 expectedText = "CONNECT localhost:80 HTTP/1.1\r\n"
665 "User-Agent: aria2\r\n"
666 "Host: localhost:80\r\n"
667 //"Proxy-Connection: Keep-Alive\r\n"
668 "\r\n";
669
670 CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createProxyRequest());
671
672 request->setKeepAliveHint(false);
673 // pipelining also adds Keep-Alive header.
674 request->setPipeliningHint(true);
675
676 expectedText = "CONNECT localhost:80 HTTP/1.1\r\n"
677 "User-Agent: aria2\r\n"
678 "Host: localhost:80\r\n"
679 //"Proxy-Connection: Keep-Alive\r\n"
680 "\r\n";
681
682 CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createProxyRequest());
683
684 // test proxy authorization
685 CPPUNIT_ASSERT(proxyRequest->setUri(
686 "http://aria2proxyuser:aria2proxypasswd@localhost:9000"));
687
688 expectedText = "CONNECT localhost:80 HTTP/1.1\r\n"
689 "User-Agent: aria2\r\n"
690 "Host: localhost:80\r\n"
691 //"Proxy-Connection: Keep-Alive\r\n"
692 "Proxy-Authorization: Basic "

Callers

nothing calls this directly

Calls 8

setUriMethod · 0.80
setSegmentMethod · 0.80
setKeepAliveHintMethod · 0.80
setPipeliningHintMethod · 0.80
setRequestMethod · 0.45
setProxyRequestMethod · 0.45
createProxyRequestMethod · 0.45

Tested by

no test coverage detected