1/*
2 * Copyright 2010-2017 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
5#ifndef _B_URL_PROTOCOL_LISTENER_H_
6#define _B_URL_PROTOCOL_LISTENER_H_
7
8
9#include <stddef.h>
10#include <cstdlib>
11
12#include <UrlResult.h>
13
14
15class BCertificate;
16
17
18namespace BPrivate {
19
20namespace Network {
21
22
23class BUrlRequest;
24
25
26enum BUrlProtocolDebugMessage {
27	B_URL_PROTOCOL_DEBUG_TEXT,
28	B_URL_PROTOCOL_DEBUG_ERROR,
29	B_URL_PROTOCOL_DEBUG_HEADER_IN,
30	B_URL_PROTOCOL_DEBUG_HEADER_OUT,
31	B_URL_PROTOCOL_DEBUG_TRANSFER_IN,
32	B_URL_PROTOCOL_DEBUG_TRANSFER_OUT
33};
34
35
36class BUrlProtocolListener {
37public:
38	virtual	void				ConnectionOpened(BUrlRequest* caller);
39	virtual	void				HostnameResolved(BUrlRequest* caller,
40									const char* ip);
41	virtual	void				ResponseStarted(BUrlRequest* caller);
42	virtual	void				HeadersReceived(BUrlRequest* caller);
43	virtual	void				BytesWritten(BUrlRequest* caller,
44									size_t bytesWritten);
45	virtual	void				DownloadProgress(BUrlRequest* caller,
46									off_t bytesReceived, off_t bytesTotal);
47	virtual void				UploadProgress(BUrlRequest* caller,
48									off_t bytesSent, off_t bytesTotal);
49
50	virtual	void				RequestCompleted(BUrlRequest* caller,
51									bool success);
52	virtual	void				DebugMessage(BUrlRequest* caller,
53									BUrlProtocolDebugMessage type,
54									const char* text);
55	virtual	bool				CertificateVerificationFailed(
56									BUrlRequest* caller,
57									BCertificate& certificate,
58									const char* message);
59};
60
61
62} // namespace Network
63
64} // namespace BPrivate
65
66#endif // _B_URL_PROTOCOL_LISTENER_H_
67