History log of /haiku/src/kits/package/FetchFileJob.cpp
Revision Date Author Comments
# fa1e07fa 14-Jul-2021 Adrien Destugues <pulkomandy@pulkomandy.tk>

Package kit: fix error handling in case of HTTP errors

HTTP errors can have some content sent with them (a message to display
to the user, usually). The package kit would not ignore this and append
the content to the end of the downloaded file. This could result in a
file larger than the expected size, and in that case, it would keep
growing infinitely by adding more error messages to it.

Also add some more specific error messages for some HTTP codes, in
particular, "invalid range" which is likely to happen if something goes
wrong with range requests. Now this case will be detected and the
download will stop.

Change-Id: I18927f361235e9f72a5701c1bd7977abda9e21ad
Reviewed-on: https://review.haiku-os.org/c/haiku/+/4210
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# ec8bba15 02-Mar-2021 Niels Sascha Reedijk <niels.reedijk@gmail.com>

PackageKit: fix download logic for remote files

This was broken in hrev54968, as some code was lost while switching to the new
way the network services kits writes files to disk.

This should fix #16822

Change-Id: I104d82e268ded287fd64db1cb902f94b71bad53b
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3760
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# 78b14420 24-Jul-2020 Leorize <leorize+oss@disroot.org>

libbnetapi: BUrlRequest now outputs to BDataIO

Previously, BUrlRequest returns data received via a callback that can't
return any value. This approach have several issues:

- It's not possible to signify failures to the request.
- Users have to implement custom listeners just to handle the common
case of outputting to a buffer/file/etc.
- The received data has to be serialized into BMessage when
BUrlProtocolDispatchingListener is employed. This can cause a
noticible slowdown in real-world scenarios as evident by #10748.

With this change, BUrlRequest will output directly into a BDataIO, which
exposes a richer API for request handlers to work with (for example a
BitTorrent client can request a BPositionIO for non-linear data
delivery), as well as simplifying common cases for users.

The adaptation only requires one additional API:
BHttpRequest::SetStopOnError(). This API simply instructs the HTTP
request handler to cancel the request if an HTTP error is occurred.

Change-Id: I4160884d77bff0e7678e0a623e2587987704443a
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3084
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# 1a0b4125 28-Jan-2021 Niels Sascha Reedijk <niels.reedijk@gmail.com>

libpackage.so: change UrlProtocolListener size types to off_t

Missed this use after changing the definition in hrev54926

Change-Id: I046560ec73dfb3ed6284513a34228b8343c5cf40


# 8579c7fa 23-Jan-2021 Niels Sascha Reedijk <niels.reedijk@gmail.com>

Package Kit: switch to libnetservices.a

Switch to the experimental services API as the copy in libbnetapi.so is
deprecated.

Change-Id: Ia0742038937d078c6a59ae13180a00a4c4eeb177
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3671
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>


# bc1e082b 10-Jan-2021 Stephan Aßmus <superstippi@gmx.de>

BHttpRequest: Treat incomplete downloads as error

When BSocket::Read() returns 0, it was treated as
a finished transfer. This is OK when we don't know
the content length, but when we do, there is no reason
not to bubble up the error. Return B_IO_ERROR in this
case.

Change-Id: I68801dbbb85bcfd2e7aa68fd6a9ded6304e82b19
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3621
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# f15516ff 19-Nov-2020 Adrien Destugues <pulkomandy@pulkomandy.tk>

Package Kit: re-use downloads from unfinished transactions

There are three parts to this change:
- In FetchFileJob, if the request fails with a timeout or IO error
(probably because of unstable connection) attempt to resume the
download with a range request. No limit on number of retries
currently, maybe we should add one.
- In PackageManager, before downloading a file, look around in other
transaction directories in case it's already there. Partial and
complete downloads are differentiated by an attribute which the
fetch file job maintains. For complete downloads, no fetch job is
scheduled, for partial downloads, the fetch job will request the
remainder of the file.
- In BHttpRequest, the implementation of SetRangeStart() and
SetRangeEnd() have been added, along with some refactoring to
handle listener notifications consistently. This also fixed a
bug where the final notification for download progress was not
emitted for compressed data.

Fixes #12414.

Change-Id: I3e285741ed0e5651594a7c2e1c7170644a9d297d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3404
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>


# b3de8bea 04-Feb-2020 X512 <danger_mail@list.ru>

Package Kit: convert HTTP error code only on BHttpRequest

Other request types exists such as BFileRequest.

Fixes #15675.

Change-Id: Ib2e07fad4dd9f682d2b9fc0cdbf0ca60ecd3adfb
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2200
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
Reviewed-by: François Revol <revol@free.fr>


# 0ef0921d 03-Feb-2020 François Revol <revol@free.fr>

Package Kit: Return proper errors in FetchFileJob

This should give more meaningful errors in pkgman
(not so sure, feel free to tweak the mapping),
and also avoid running the next job if fetching failed.

Change-Id: If76968f705ff25f7ecf1a5f91d88a02040d24665
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2186
Reviewed-by: Ryan Leavengood <leavengood@gmail.com>


# 4a3dae2b 07-Oct-2018 François Revol <revol@free.fr>

package kit: add a NULL check on requests

This avoid crashing on malformed repository URL (like missing http://).


# 106ae4ec 17-Aug-2018 CodeforEvolution <themysterymail555@gmail.com>

Remove Curl, Switch to NetApi in Package Kit

Change-Id: I92213ab60dc987175c323d1d9ed11ac8b3517f2f
Reviewed-on: https://review.haiku-os.org/475
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# 55557aa1 27-Jul-2018 JackBurton79 <stefano.ceccherini@gmail.com>

CURLOPT_XFERINFOFUNCTION is available since libcurl 7.32.0 only.
Since it's just cosmetic, allow compiling with older libcurl, too.
fixes build on RedHat/CentOS 7

Change-Id: I169ad84d15e61012d1d38a9b41af7eef81683bf7


# a00bd28a 07-Oct-2017 Adrien Destugues <pulkomandy@pulkomandy.tk>

Package Kit: map some curl errors to Be error codes

Trying to get something more useful than "aborted: no error" in case of
network errors in pkgman.


# 3c08e456 05-Apr-2015 Adrien Destugues <pulkomandy@gmail.com>

Fix package download progress computation.

The download progress and total used to be doubles, but now they are
off_t. This resulted in the division being done in integers, and always
getting 0 as the result.

Fixes #11940.


# 1aaa0c21 24-Jan-2015 Axel Dörfler <axeld@pinc-software.de>

Package Kit: FetchFileJob now contains package size.

* So that you know how much already was, and still has to be downloaded.
* Automatic whitespace cleanup.
* The link in FetchFileJob.h did not fetch the correct header under
Haiku anymore (since the addition of the private headers to the
image).


# 42c73714 25-Jul-2014 Oliver Tappe <zooey@hirschkaefer.de>

Let Package-Kit's FetchFileJob handle redirects.

* additionally, drop duplicate setting of CURLOPT_PROGRESSFUNCTION.


# 800d5376 26-Jan-2014 Alexander von Gluck IV <kallisti5@unixzen.com>

package kit: Disable curl requirement on bootstrap build

* As per the mailing list.
* Introduce HAIKU_BOOTSTRAP_BUILD define to sources
to let them know they are taking part in a bootstrap


# 9345049a 28-Sep-2013 Rene Gollent <anevilyak@gmail.com>

Package Kit: Implement progress notifications.

- BJobStateListener: Add progress state and corresponding hook.
- FetchFileJob: Notify job progress hook on libcurl notifications.
- UserInteractionHandler: Add hooks for download progress and checksum
validation progress.
- PackageManager: inherit from JobStateListener and watch for job
notifications for internally generated jobs. Forward to corresponding
UserInteractionHandler hooks as needed.
- Adapt pkgman, HaikuDepot and package_daemon to above changes.
Neither HaikuDepot nor package_daemon's progress hooks are wired up to
do anything yet though.


# cd76e090 24-Sep-2013 Rene Gollent <anevilyak@gmail.com>

libpackage: Use libcurl directly for downloads.

- Initial step towards allowing listening for download progress.


# 7d7ed9bf 25-Jan-2011 Oliver Tappe <zooey@hirschkaefer.de>

Mostly style-related changes to package kit:
* drop 'Haiku' namespace
* rename 'Package' namespace to 'BPackageKit'
* renamed all public classes to begin with a 'B'
* renamed BPackageKit::Roster to BPackageKit::BPackageRoster to not
clash with the BRoster from the application kit.
* fix some instances of public headers including private ones

Some functional changes, too:
* JobQueue now removes and deletes dependants of failed jobs
automatically
* JobQueue supports waiting for jobs to become runnable
* added a couple of InitCheck() methods where they make sense
and invoke those in users of these classes



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40287 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 35edda8f 24-Jan-2011 Oliver Tappe <zooey@hirschkaefer.de>

* more work on the package kit, repositories can now be added and
refreshed


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40280 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 11a4ecfd 22-Jan-2011 Oliver Tappe <zooey@hirschkaefer.de>

* added support for interactive decisions to package kit and pkgman


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40268 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 500bb630 21-Jan-2011 Oliver Tappe <zooey@hirschkaefer.de>

* WIP-commit of the first parts of the package kit and the pkgman
(console-)tool


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40261 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 3c08e456131e6cd40063bcb1c1e889e452c2feb8 05-Apr-2015 Adrien Destugues <pulkomandy@gmail.com>

Fix package download progress computation.

The download progress and total used to be doubles, but now they are
off_t. This resulted in the division being done in integers, and always
getting 0 as the result.

Fixes #11940.


# 1aaa0c2142c6c843e93bd1ee8edd4c7ea6256559 24-Jan-2015 Axel Dörfler <axeld@pinc-software.de>

Package Kit: FetchFileJob now contains package size.

* So that you know how much already was, and still has to be downloaded.
* Automatic whitespace cleanup.
* The link in FetchFileJob.h did not fetch the correct header under
Haiku anymore (since the addition of the private headers to the
image).


# 42c73714726c54c33b5dd9dbfb9c5cdf24445215 25-Jul-2014 Oliver Tappe <zooey@hirschkaefer.de>

Let Package-Kit's FetchFileJob handle redirects.

* additionally, drop duplicate setting of CURLOPT_PROGRESSFUNCTION.


# 800d5376f9a36d92eb1fe3a254d0f53356a4046b 26-Jan-2014 Alexander von Gluck IV <kallisti5@unixzen.com>

package kit: Disable curl requirement on bootstrap build

* As per the mailing list.
* Introduce HAIKU_BOOTSTRAP_BUILD define to sources
to let them know they are taking part in a bootstrap


# 9345049af828506bd2b20408e3612655a0153db1 28-Sep-2013 Rene Gollent <anevilyak@gmail.com>

Package Kit: Implement progress notifications.

- BJobStateListener: Add progress state and corresponding hook.
- FetchFileJob: Notify job progress hook on libcurl notifications.
- UserInteractionHandler: Add hooks for download progress and checksum
validation progress.
- PackageManager: inherit from JobStateListener and watch for job
notifications for internally generated jobs. Forward to corresponding
UserInteractionHandler hooks as needed.
- Adapt pkgman, HaikuDepot and package_daemon to above changes.
Neither HaikuDepot nor package_daemon's progress hooks are wired up to
do anything yet though.


# cd76e0903f37330520691a80fd894ded46430af1 24-Sep-2013 Rene Gollent <anevilyak@gmail.com>

libpackage: Use libcurl directly for downloads.

- Initial step towards allowing listening for download progress.


# 7d7ed9bf4bdd7bc31e31143c402c4f96a324b30b 25-Jan-2011 Oliver Tappe <zooey@hirschkaefer.de>

Mostly style-related changes to package kit:
* drop 'Haiku' namespace
* rename 'Package' namespace to 'BPackageKit'
* renamed all public classes to begin with a 'B'
* renamed BPackageKit::Roster to BPackageKit::BPackageRoster to not
clash with the BRoster from the application kit.
* fix some instances of public headers including private ones

Some functional changes, too:
* JobQueue now removes and deletes dependants of failed jobs
automatically
* JobQueue supports waiting for jobs to become runnable
* added a couple of InitCheck() methods where they make sense
and invoke those in users of these classes



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40287 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 35edda8f0befb8667b593e2314f6d555a7db44d8 24-Jan-2011 Oliver Tappe <zooey@hirschkaefer.de>

* more work on the package kit, repositories can now be added and
refreshed


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40280 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 11a4ecfd82c31ded8ba33ad2ac5f5a6538b7fa40 22-Jan-2011 Oliver Tappe <zooey@hirschkaefer.de>

* added support for interactive decisions to package kit and pkgman


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40268 a95241bf-73f2-0310-859d-f6bbb57e9c96


# 500bb6305c339017d7d7302dc1f63ac90443f267 21-Jan-2011 Oliver Tappe <zooey@hirschkaefer.de>

* WIP-commit of the first parts of the package kit and the pkgman
(console-)tool


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40261 a95241bf-73f2-0310-859d-f6bbb57e9c96