| 758 | } |
| 759 | |
| 760 | void HttpRequestTest::testUserAgent() |
| 761 | { |
| 762 | auto request = std::make_shared<Request>(); |
| 763 | request->setUri("http://localhost:8080/archives/aria2-1.0.0.tar.bz2"); |
| 764 | |
| 765 | // std::shared_ptr<Piece> p(new Piece(0, 1_k)); |
| 766 | // std::shared_ptr<Segment> segment(new PiecedSegment(1_k, p)); |
| 767 | |
| 768 | HttpRequest httpRequest; |
| 769 | httpRequest.disableContentEncoding(); |
| 770 | httpRequest.setRequest(request); |
| 771 | // httpRequest.setSegment(segment); |
| 772 | httpRequest.setUserAgent("aria2 (Linux)"); |
| 773 | httpRequest.setAuthConfigFactory(authConfigFactory_.get()); |
| 774 | httpRequest.setOption(option_.get()); |
| 775 | httpRequest.setNoWantDigest(true); |
| 776 | |
| 777 | std::string expectedText = "GET /archives/aria2-1.0.0.tar.bz2 HTTP/1.1\r\n" |
| 778 | "User-Agent: aria2 (Linux)\r\n" |
| 779 | "Accept: */*\r\n" |
| 780 | "Host: localhost:8080\r\n" |
| 781 | "Pragma: no-cache\r\n" |
| 782 | "Cache-Control: no-cache\r\n" |
| 783 | "Connection: close\r\n" |
| 784 | "\r\n"; |
| 785 | |
| 786 | CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest()); |
| 787 | |
| 788 | auto proxyRequest = std::make_shared<Request>(); |
| 789 | CPPUNIT_ASSERT(proxyRequest->setUri("http://localhost:9000")); |
| 790 | |
| 791 | httpRequest.setProxyRequest(proxyRequest); |
| 792 | |
| 793 | std::string expectedTextForProxy = "CONNECT localhost:8080 HTTP/1.1\r\n" |
| 794 | "User-Agent: aria2 (Linux)\r\n" |
| 795 | "Host: localhost:8080\r\n" |
| 796 | //"Proxy-Connection: close\r\n" |
| 797 | "\r\n"; |
| 798 | |
| 799 | CPPUNIT_ASSERT_EQUAL(expectedTextForProxy, httpRequest.createProxyRequest()); |
| 800 | } |
| 801 | |
| 802 | void HttpRequestTest::testAddHeader() |
| 803 | { |
nothing calls this directly
no test coverage detected