blob: 37f82f9f7b514a1919432326c9662a4f0736d7b2 (
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
59
60
61
62
63
64
65
66
67
68
69
|
#include "conn.h"
#include <util/network/socket.h>
#include <util/stream/buffered.h>
class THttpServerConn::TImpl {
public:
inline TImpl(const TSocket& s, size_t outputBufferSize)
: S_(s)
, SI_(S_)
, SO_(S_)
, BO_(&SO_, outputBufferSize)
, HI_(&SI_)
, HO_(&BO_, &HI_)
{
}
inline ~TImpl() {
}
inline THttpInput* Input() noexcept {
return &HI_;
}
inline THttpOutput* Output() noexcept {
return &HO_;
}
inline void Reset() {
if (S_ != INVALID_SOCKET) {
// send RST packet to client
S_.SetLinger(true, 0);
S_.Close();
}
}
private:
TSocket S_;
TSocketInput SI_;
TSocketOutput SO_;
TBufferedOutput BO_;
THttpInput HI_;
THttpOutput HO_;
};
THttpServerConn::THttpServerConn(const TSocket& s)
: THttpServerConn(s, s.MaximumTransferUnit())
{
}
THttpServerConn::THttpServerConn(const TSocket& s, size_t outputBufferSize)
: Impl_(new TImpl(s, outputBufferSize))
{
}
THttpServerConn::~THttpServerConn() {
}
THttpInput* THttpServerConn::Input() noexcept {
return Impl_->Input();
}
THttpOutput* THttpServerConn::Output() noexcept {
return Impl_->Output();
}
void THttpServerConn::Reset() {
return Impl_->Reset();
}
|