blob: 62a3e86ac953765cdd2828bd5444b38c0c8b1140 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#pragma once
#include <library/cpp/http/io/stream.h>
#include <util/generic/ptr.h>
#include <util/stream/buffered.h>
class IInputStream;
class IOutputStream;
class TSocket;
/// Потоки ввода/вывода для получения запросов и отправки ответов HTTP-сервера.
class THttpServerConn {
public:
class ISocketStreams {
public:
virtual ~ISocketStreams() {}
virtual IInputStream* Input() = 0;
virtual IOutputStream* Output() = 0;
virtual void Reset() = 0;
};
public:
THttpServerConn(const TSocket& s);
THttpServerConn(const TSocket& s, size_t outputBufferSize);
THttpServerConn(THolder<ISocketStreams> socketStreams, size_t outputBufferSize);
~THttpServerConn();
THttpInput* Input() noexcept {
return &HttpInput_;
}
THttpOutput* Output() noexcept {
return &HttpOutput_;
}
inline const THttpInput* Input() const noexcept {
return const_cast<THttpServerConn*>(this)->Input();
}
inline const THttpOutput* Output() const noexcept {
return const_cast<THttpServerConn*>(this)->Output();
}
/// Проверяет, можно ли установить режим, при котором соединение с сервером
/// не завершается после окончания транзакции.
inline bool CanBeKeepAlive() const noexcept {
return Output()->CanBeKeepAlive();
}
void Reset();
private:
THolder<ISocketStreams> SocketStreams_;
TBufferedOutput BufferedOutput_;
THttpInput HttpInput_;
THttpOutput HttpOutput_;
};
|