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

Method handleDefaultEncoding

src/HttpResponseCommand.cc:351–399  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349}
350
351bool HttpResponseCommand::handleDefaultEncoding(
352 std::unique_ptr<HttpResponse> httpResponse)
353{
354 auto progressInfoFile = std::make_shared<DefaultBtProgressInfoFile>(
355 getDownloadContext(), std::shared_ptr<PieceStorage>{}, getOption().get());
356 getRequestGroup()->adjustFilename(progressInfoFile);
357 getRequestGroup()->initPieceStorage();
358
359 if (getOption()->getAsBool(PREF_DRY_RUN)) {
360 onDryRunFileFound();
361 return true;
362 }
363
364 auto checkEntry = getRequestGroup()->createCheckIntegrityEntry();
365 if (!checkEntry) {
366 return true;
367 }
368
369 File file(getRequestGroup()->getFirstFilePath());
370 // We have to make sure that command that has Request object must
371 // have segment after PieceStorage is initialized. See
372 // AbstractCommand::execute()
373 auto segment = getSegmentMan()->getSegmentWithIndex(getCuid(), 0);
374 // pipelining requires implicit range specified. But the request for
375 // this response most likely doesn't contains range header. This means
376 // we can't continue to use this socket because server sends all entity
377 // body instead of a segment.
378 // Therefore, we shutdown the socket here if pipelining is enabled.
379 if (getRequest()->getMethod() == Request::METHOD_GET && segment &&
380 segment->getPositionToWrite() == 0 &&
381 !getRequest()->isPipeliningEnabled()) {
382 auto teFilter = getTransferEncodingStreamFilter(httpResponse.get());
383 checkEntry->pushNextCommand(createHttpDownloadCommand(
384 std::move(httpResponse), std::move(teFilter)));
385 }
386 else {
387 getSegmentMan()->cancelSegment(getCuid());
388 getFileEntry()->poolRequest(getRequest());
389 }
390
391 prepareForNextAction(std::move(checkEntry));
392
393 if (getRequest()->getMethod() == Request::METHOD_HEAD) {
394 poolConnection();
395 getRequest()->setMethod(Request::METHOD_GET);
396 }
397
398 return true;
399}
400
401bool HttpResponseCommand::handleOtherEncoding(
402 std::unique_ptr<HttpResponse> httpResponse)

Callers

nothing calls this directly

Calls 14

adjustFilenameMethod · 0.80
initPieceStorageMethod · 0.80
getAsBoolMethod · 0.80
getFirstFilePathMethod · 0.80
getSegmentWithIndexMethod · 0.80
isPipeliningEnabledMethod · 0.80
pushNextCommandMethod · 0.80
cancelSegmentMethod · 0.80
poolRequestMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected