60355daec9
The integration PostTest has a basic test that the expected messages are sent and have the expected data fields. The gist is documented in book.dox. To do are the messages around SSL. However, that functionality is also not implemented yet, so there is nothing to send. Change-Id: Ib8f36ed32f9854d643d8256338b71af7067059f0
110 lines
2.0 KiB
C++
110 lines
2.0 KiB
C++
/*
|
|
* Copyright 2021 Haiku Inc. All rights reserved.
|
|
* Distributed under the terms of the MIT License.
|
|
*/
|
|
|
|
#ifndef _NETSERVICES_DEFS_H_
|
|
#define _NETSERVICES_DEFS_H_
|
|
|
|
|
|
#include <ErrorsExt.h>
|
|
#include <StringList.h>
|
|
#include <Url.h>
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
namespace Network {
|
|
|
|
|
|
// Standard exceptions
|
|
class BUnsupportedProtocol : public BError {
|
|
public:
|
|
BUnsupportedProtocol(const char* origin, BUrl url,
|
|
BStringList supportedProtocols);
|
|
BUnsupportedProtocol(BString origin, BUrl url,
|
|
BStringList supportedProtocols);
|
|
|
|
virtual const char* Message() const noexcept override;
|
|
|
|
const BUrl& Url() const;
|
|
const BStringList& SupportedProtocols() const;
|
|
|
|
private:
|
|
BUrl fUrl;
|
|
BStringList fSupportedProtocols;
|
|
};
|
|
|
|
|
|
class BInvalidUrl : public BError {
|
|
public:
|
|
BInvalidUrl(const char* origin, BUrl url);
|
|
BInvalidUrl(BString origin, BUrl url);
|
|
|
|
virtual const char* Message() const noexcept override;
|
|
|
|
const BUrl& Url() const;
|
|
|
|
private:
|
|
BUrl fUrl;
|
|
};
|
|
|
|
|
|
class BNetworkRequestError : public BError {
|
|
public:
|
|
enum ErrorType {
|
|
HostnameError,
|
|
NetworkError,
|
|
ProtocolError,
|
|
SystemError,
|
|
Canceled
|
|
};
|
|
|
|
BNetworkRequestError(const char* origin, ErrorType type,
|
|
status_t errorCode = B_OK);
|
|
|
|
virtual const char* Message() const noexcept override;
|
|
virtual BString DebugMessage() const override;
|
|
|
|
ErrorType Type() const noexcept;
|
|
status_t ErrorCode() const noexcept;
|
|
|
|
private:
|
|
ErrorType fErrorType;
|
|
status_t fErrorCode = B_OK;
|
|
};
|
|
|
|
|
|
BString encode_to_base64(const BString& string);
|
|
|
|
|
|
namespace UrlEvent {
|
|
enum {
|
|
HostNameResolved = '_NHR',
|
|
ConnectionOpened = '_NCO',
|
|
UploadProgress = '_NUP',
|
|
ResponseStarted = '_NRS',
|
|
DownloadProgress = '_NDP',
|
|
BytesWritten = '_NBW',
|
|
RequestCompleted = '_NRC',
|
|
DebugMessage = '_NDB'
|
|
};
|
|
}
|
|
|
|
|
|
namespace UrlEventData {
|
|
extern const char* Id;
|
|
extern const char* HostName;
|
|
extern const char* NumBytes;
|
|
extern const char* TotalBytes;
|
|
extern const char* Success;
|
|
extern const char* DebugType;
|
|
extern const char* DebugMessage;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|