haiku/docs/user/netservices/UrlProtocolRoster.dox
Leorize 78b1442051 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>
2021-02-28 20:39:31 +00:00

45 lines
1.2 KiB
Plaintext

/*
* Copyright 2020 Haiku, Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Leorize, leorize+oss@disroot.org
*
* Corresponds to:
* headers/private/netservices/UrlProtocolRoster.h hrev54923
* src/kits/network/libnetservices/UrlProtocolRoster.cpp hrev54923
*/
/*!
\file UrlProtocolRoster.h
\ingroup netservices
\brief Provides the BUrlProtocolRoster interface.
*/
/*!
\class BPrivate::Network::BUrlProtocolRoster
\ingroup netservices
\brief Interfaces for protocol-agnostic operations.
*/
/*!
\fn static BUrlRequest* BUrlProtocolRoster::MakeRequest(const BUrl& url,
BDataIO* output, BUrlProtocolListener* listener = NULL,
BUrlContext* context = NULL)
\brief Create a BUrlRequest that can handle the given BUrl
\param url The URL to create a request for
\param output The BDataIO to output to
\param listener The BUrlProtocolListener to be registered with the created
BUrlRequest, can be \c NULL
\param context The BUrlContext to be registered with the created
BUrlRequest, can be \c NULL
\returns A pointer to the BUrlRequest that can handle the given BUrl.
\c NULL will be returned if there aren't any BUrlRequest that can
handle the given protocol or if memory couldn't be allocated.
*/