forked from pocoproject/poco
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApacheStream.cpp
More file actions
executable file
·122 lines (86 loc) · 1.69 KB
/
ApacheStream.cpp
File metadata and controls
executable file
·122 lines (86 loc) · 1.69 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//
// ApacheStream.h
//
// $Id: //poco/1.4/ApacheConnector/src/ApacheStream.cpp#2 $
//
// Copyright (c) 2006-2011, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "ApacheStream.h"
#include "ApacheConnector.h"
#include "Poco/Exception.h"
using Poco::BufferedStreamBuf;
//
// ApacheStreamBuf
//
ApacheStreamBuf::ApacheStreamBuf(ApacheRequestRec* pApacheRequest, bool haveData):
BufferedStreamBuf(STREAM_BUFFER_SIZE, std::ios::in | std::ios::out),
_pApacheRequest(pApacheRequest),
_haveData(haveData)
{
}
ApacheStreamBuf::~ApacheStreamBuf()
{
}
int ApacheStreamBuf::readFromDevice(char* buffer, std::streamsize len)
{
if (_haveData)
return _pApacheRequest->readRequest(buffer, static_cast<int>(len));
else
return 0;
}
int ApacheStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
{
_pApacheRequest->writeResponse(buffer, length);
return length;
}
//
// ApacheIOS
//
ApacheIOS::ApacheIOS(ApacheRequestRec* pApacheRequest, bool haveData):
_buf(pApacheRequest, haveData)
{
poco_ios_init(&_buf);
}
ApacheIOS::~ApacheIOS()
{
try
{
_buf.sync();
}
catch (...)
{
}
}
ApacheStreamBuf* ApacheIOS::rdbuf()
{
return &_buf;
}
void ApacheIOS::close()
{
_buf.sync();
}
//
// ApacheOutputStream
//
ApacheOutputStream::ApacheOutputStream(ApacheRequestRec* pApacheRequest):
ApacheIOS(pApacheRequest),
std::ostream(&_buf)
{
}
ApacheOutputStream::~ApacheOutputStream()
{
}
//
// ApacheInputStream
//
ApacheInputStream::ApacheInputStream(ApacheRequestRec* pApacheRequest):
ApacheIOS(pApacheRequest, pApacheRequest->haveRequestBody()),
std::istream(&_buf)
{
}
ApacheInputStream::~ApacheInputStream()
{
}