haiku/headers/private/netservices/HttpResult.h
Leorize 3e27f8d5a7 libbnetservices: BUrlResult is no longer a BArchivable
The switch to make BUrlResult serializable was debuted in
f9e1854f19 with the rationale is that
BHttpRequest auto-redirection might cause the headers to become
obsolete by the time a client process the BMessage received from
BUrlProtocolDispatchingListener.

With the change to BHttpRequest to not notify listeners when
auto-redirection is enabled, this is no longer the case and the
serialization code can go away now. This simplifies BUrlResult and its
subclasses, and gain us some performance for clients using
BUrlProtocolDispatchingListener as the result object no longer has to be
serialized.

This also change the ABI of BUrlProtocolListener::HeadersReceived to no
longer passing a BUrlResult.

Additionally, BUrlResult and BHttpResult now express the size of the content
as an off_t, thus allowing results larger than 4 GB.

Change-Id: I9dd29a8b26fdd9aa8e5bbad8d1728084f136312d
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3082
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
2021-02-28 20:39:31 +00:00

79 lines
1.5 KiB
C++

/*
* Copyright 2010-2017 Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _B_HTTP_RESULT_H_
#define _B_HTTP_RESULT_H_
#include <iostream>
#include <HttpHeaders.h>
#include <String.h>
#include <Url.h>
#include <UrlResult.h>
#ifndef LIBNETAPI_DEPRECATED
namespace BPrivate {
namespace Network {
#endif
class BUrlRequest;
class BHttpResult: public BUrlResult {
friend class BHttpRequest;
public:
BHttpResult(const BUrl& url);
#ifdef LIBNETAPI_DEPRECATED
BHttpResult(BMessage*);
#endif
BHttpResult(const BHttpResult& other);
~BHttpResult();
// Result parameters modifications
void SetUrl(const BUrl& url);
// Result parameters access
const BUrl& Url() const;
BString ContentType() const;
#ifdef LIBNETAPI_DEPRECATED
size_t Length() const;
#else
off_t Length() const;
#endif
// HTTP-Specific stuff
const BHttpHeaders& Headers() const;
const BString& StatusText() const;
int32 StatusCode() const;
// Result tests
bool HasHeaders() const;
// Overloaded members
BHttpResult& operator=(const BHttpResult& other);
#ifdef LIBNETAPI_DEPRECATED
virtual status_t Archive(BMessage*, bool) const;
static BArchivable* Instantiate(BMessage*);
#endif
private:
BUrl fUrl;
BHttpHeaders fHeaders;
int32 fStatusCode;
BString fStatusString;
};
#ifndef LIBNETAPI_DEPRECATED
} // namespace Network
} // namespace BPrivate
#endif
#endif // _B_URL_RESULT_H_