f9e1854f19
The asynchronous listener had no reliable way to access HTTP result and headers from the callbacks. As the callbacks are triggered asynchronously, they can be run after the request has carried on and, for example, followed an HTTP redirect, clearing its internal state. The HeadersReceived callback now passes a reference to BUrlResult for the request. There are two cases: - Synchronous listener: passes a reference to the request's results directly - Asynchronous listener: archives a copy of the result into the notification message, and passes a reference to the unarchived copy. Unfortunately this comes with several ABI and API breakages: - Change to the prototype of HeadersReceived() - Change to the class hierarchy of BUrlResult (implements BArchivable) All users of HTTP requests will need to be updated if they implemented in HeadersReceived or used BUrlResult.
35 lines
663 B
C++
35 lines
663 B
C++
/*
|
|
* Copyright 2010-2017 Haiku Inc. All rights reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
#ifndef _B_URL_RESULT_H_
|
|
#define _B_URL_RESULT_H_
|
|
|
|
|
|
#include <Archivable.h>
|
|
#include <String.h>
|
|
|
|
|
|
class BUrlResult: public BArchivable {
|
|
public:
|
|
BUrlResult();
|
|
BUrlResult(BMessage*);
|
|
virtual ~BUrlResult();
|
|
|
|
virtual status_t Archive(BMessage*, bool) const;
|
|
|
|
void SetContentType(BString contentType);
|
|
void SetLength(size_t length);
|
|
|
|
virtual BString ContentType() const;
|
|
virtual size_t Length() const;
|
|
|
|
static BArchivable* Instantiate(BMessage*);
|
|
|
|
private:
|
|
BString fContentType;
|
|
size_t fLength;
|
|
};
|
|
|
|
#endif
|