2022-03-05 17:56:57 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2022 Haiku Inc. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _B_HTTP_RESULT_H_
|
|
|
|
#define _B_HTTP_RESULT_H_
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <String.h>
|
|
|
|
|
2022-04-15 08:56:18 +03:00
|
|
|
class BDataIO;
|
|
|
|
|
2022-03-05 17:56:57 +03:00
|
|
|
|
|
|
|
namespace BPrivate {
|
|
|
|
|
|
|
|
namespace Network {
|
|
|
|
|
2022-04-15 08:56:18 +03:00
|
|
|
class BHttpFields;
|
2022-03-05 17:56:57 +03:00
|
|
|
struct HttpResultPrivate;
|
|
|
|
|
|
|
|
|
2022-04-15 08:56:18 +03:00
|
|
|
struct BHttpBody
|
|
|
|
{
|
|
|
|
std::unique_ptr<BDataIO> target = nullptr;
|
|
|
|
BString text;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-03-05 17:56:57 +03:00
|
|
|
struct BHttpStatus
|
|
|
|
{
|
|
|
|
int16 code = 0;
|
|
|
|
BString text;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class BHttpResult
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// Constructors and destructor
|
|
|
|
BHttpResult(const BHttpResult& other) = delete;
|
|
|
|
BHttpResult(BHttpResult&& other) noexcept;
|
|
|
|
~BHttpResult();
|
|
|
|
|
|
|
|
// Assignment operators
|
|
|
|
BHttpResult& operator=(const BHttpResult& other) = delete;
|
|
|
|
BHttpResult& operator=(BHttpResult&& other) noexcept;
|
|
|
|
|
|
|
|
// Blocking Access Functions
|
|
|
|
const BHttpStatus& Status() const;
|
2022-04-15 08:56:18 +03:00
|
|
|
const BHttpFields& Fields() const;
|
|
|
|
BHttpBody& Body() const;
|
2022-03-05 17:56:57 +03:00
|
|
|
|
|
|
|
// Check if data is available yet
|
|
|
|
bool HasStatus() const;
|
2022-04-15 08:56:18 +03:00
|
|
|
bool HasFields() const;
|
2022-03-05 17:56:57 +03:00
|
|
|
bool HasBody() const;
|
|
|
|
bool IsCompleted() const;
|
|
|
|
|
|
|
|
// Identity
|
|
|
|
int32 Identity() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend class BHttpSession;
|
|
|
|
BHttpResult(std::shared_ptr<HttpResultPrivate> data);
|
|
|
|
std::shared_ptr<HttpResultPrivate> fData;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace Network
|
|
|
|
|
|
|
|
} // namespace BPrivate
|
|
|
|
|
|
|
|
#endif // _B_HTTP_RESPONSE_H_
|