StreamSession.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_STREAMSESSION_H
6#define PT_HTTP_STREAMSESSION_H
7
8#include <Pt/Http/Api.h>
9#include <Pt/NonCopyable.h>
10
11namespace Pt {
12
13namespace Http {
14
15class Stream;
16
53class PT_HTTP_API StreamSession : private NonCopyable
54{
55 friend class Stream;
56
57 public:
60 bool isOpen() const
61 { return _stream != 0; }
62
63 protected:
67
72 explicit StreamSession(Stream& stream);
73
77
83 void open(Stream& stream);
84
91 void close();
92
95 Stream* stream() const
96 { return _stream; }
97
98 protected:
99 void closeStream(Stream& stream);
100
105 virtual void onCloseStream(Stream& stream);
106
107 private:
108 Stream* _stream;
109};
110
111} // namespace Http
112
113} // namespace Pt
114
115#endif // PT_HTTP_STREAMSESSION_H
bool isOpen() const
Returns true when a stream is bound.
Definition StreamSession.h:60
Stream * stream() const
Returns the bound stream, or null.
Definition StreamSession.h:95
StreamSession()
Creates a session with no stream.
virtual void onCloseStream(Stream &stream)
Called when the stream ends.
void close()
Unbinds and closes the stream.
void open(Stream &stream)
Binds stream.
StreamSession(Stream &stream)
Creates a session bound to stream.
~StreamSession()
Unbinds and closes the stream.
One HTTP stream on a connection.
Definition Stream.h:90
NonCopyable()
Default constructor.
Definition NonCopyable.h:63
HTTP clients and servers.
Core module.
Definition Allocator.h:33