Channel.h
1/* Copyright (C) 2026 by Marc Boris Duerner
2 SPDX-License-Identifier: LGPL-2.1-or-later WITH mif-exception
3*/
4
5#ifndef PT_HTTP_CHANNEL_H
6#define PT_HTTP_CHANNEL_H
7
8#include <Pt/Http/Api.h>
9#include <Pt/NonCopyable.h>
10
11namespace Pt {
12
13namespace Http {
14
15class Stream;
16
56class PT_HTTP_API Channel : private NonCopyable
57{
58 friend class Stream;
59
60 public:
63 bool isOpen() const
64 { return _stream != 0; }
65
71 void close();
72
73 protected:
77
82 explicit Channel(Stream& stream);
83
87
93 void open(Stream& stream);
94
97 Stream* stream() const
98 { return _stream; }
99
106 virtual void onClose();
107
108 private:
114 void onDetachStream(Stream& stream);
115
116 private:
117 Stream* _stream;
118};
119
120} // namespace Http
121
122} // namespace Pt
123
124#endif // PT_HTTP_CHANNEL_H
bool isOpen() const
Returns true when a stream is bound.
Definition Channel.h:63
Channel(Stream &stream)
Creates a channel bound to stream.
Stream * stream() const
Returns the bound stream, or null.
Definition Channel.h:97
void close()
Releases the bound stream.
~Channel()
Releases the bound stream.
void open(Stream &stream)
Binds stream.
virtual void onClose()
Cleans up before the stream pointer is dropped.
Channel()
Creates a channel with no stream.
One HTTP stream on a connection.
Definition Stream.h:92
NonCopyable()
Default constructor.
Definition NonCopyable.h:63
HTTP clients and servers.
Core module.
Definition Allocator.h:33