| 321 | } |
| 322 | |
| 323 | void 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()); |
nothing calls this directly
no test coverage detected