Skip to content

Commit 6b529b6

Browse files
committed
committed latest 1.3 snapshot
1 parent 965b945 commit 6b529b6

35 files changed

+2017
-282
lines changed

Net/Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Makefile
33
#
4-
# $Id: //poco/Main/Net/Makefile#34 $
4+
# $Id: //poco/Main/Net/Makefile#36 $
55
#
66
# Makefile for Poco Net
77
#
@@ -17,19 +17,19 @@ objects = \
1717
DatagramSocketImpl FilePartSource HTTPServerConnection MessageHeader \
1818
HTTPChunkedStream HTTPServerConnectionFactory MulticastSocket SocketStream \
1919
HTTPClientSession HTTPServerParams MultipartReader StreamSocket SocketImpl \
20-
HTTPFixedLengthStream HTTPServerRequest MultipartWriter StreamSocketImpl \
21-
HTTPHeaderStream HTTPServerResponse NameValueCollection TCPServer \
20+
HTTPFixedLengthStream HTTPServerRequest HTTPServerRequestImpl MultipartWriter StreamSocketImpl \
21+
HTTPHeaderStream HTTPServerResponse HTTPServerResponseImpl NameValueCollection TCPServer \
2222
HTTPMessage HTTPServerSession NetException TCPServerConnection HTTPBufferAllocator \
2323
HTTPRequest HTTPSession HTTPSessionInstantiator HTTPSessionFactory NetworkInterface TCPServerConnectionFactory \
2424
HTTPRequestHandler HTTPStream HTTPIOStream ServerSocket TCPServerDispatcher \
2525
HTTPRequestHandlerFactory HTTPStreamFactory ServerSocketImpl TCPServerParams \
2626
QuotedPrintableEncoder QuotedPrintableDecoder StringPartSource \
2727
FTPClientSession FTPStreamFactory PartHandler PartSource NullPartHandler \
28-
SocketReactor SocketNotifier SocketNotification \
28+
SocketReactor SocketNotifier SocketNotification AbstractHTTPRequestHandler \
2929
MailRecipient MailMessage MailStream SMTPClientSession POP3ClientSession \
3030
RawSocket RawSocketImpl ICMPClient ICMPEventArgs ICMPPacket ICMPPacketImpl \
3131
ICMPSocket ICMPSocketImpl ICMPv4PacketImpl \
32-
RemoteSyslogChannel
32+
RemoteSyslogChannel RemoteSyslogListener
3333

3434
target = PocoNet
3535
target_version = $(LIBVERSION)

Net/Net_vs71.vcproj

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,9 @@
600600
<Filter
601601
Name="Header Files"
602602
Filter="">
603+
<File
604+
RelativePath=".\include\Poco\Net\AbstractHTTPRequestHandler.h">
605+
</File>
603606
<File
604607
RelativePath=".\include\Poco\Net\HTTPRequestHandler.h">
605608
</File>
@@ -621,16 +624,25 @@
621624
<File
622625
RelativePath=".\include\Poco\Net\HTTPServerRequest.h">
623626
</File>
627+
<File
628+
RelativePath=".\include\Poco\Net\HTTPServerRequestImpl.h">
629+
</File>
624630
<File
625631
RelativePath=".\include\Poco\Net\HTTPServerResponse.h">
626632
</File>
633+
<File
634+
RelativePath=".\include\Poco\Net\HTTPServerResponseImpl.h">
635+
</File>
627636
<File
628637
RelativePath=".\include\Poco\Net\HTTPServerSession.h">
629638
</File>
630639
</Filter>
631640
<Filter
632641
Name="Source Files"
633642
Filter="">
643+
<File
644+
RelativePath=".\src\AbstractHTTPRequestHandler.cpp">
645+
</File>
634646
<File
635647
RelativePath=".\src\HTTPRequestHandler.cpp">
636648
</File>
@@ -652,9 +664,15 @@
652664
<File
653665
RelativePath=".\src\HTTPServerRequest.cpp">
654666
</File>
667+
<File
668+
RelativePath=".\src\HTTPServerRequestImpl.cpp">
669+
</File>
655670
<File
656671
RelativePath=".\src\HTTPServerResponse.cpp">
657672
</File>
673+
<File
674+
RelativePath=".\src\HTTPServerResponseImpl.cpp">
675+
</File>
658676
<File
659677
RelativePath=".\src\HTTPServerSession.cpp">
660678
</File>
@@ -885,13 +903,19 @@
885903
<File
886904
RelativePath=".\include\Poco\Net\RemoteSyslogChannel.h">
887905
</File>
906+
<File
907+
RelativePath=".\include\Poco\Net\RemoteSyslogListener.h">
908+
</File>
888909
</Filter>
889910
<Filter
890911
Name="Source Files"
891912
Filter="">
892913
<File
893914
RelativePath=".\src\RemoteSyslogChannel.cpp">
894915
</File>
916+
<File
917+
RelativePath=".\src\RemoteSyslogListener.cpp">
918+
</File>
895919
</Filter>
896920
</Filter>
897921
</Files>

Net/Net_vs80.vcproj

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,10 @@
805805
<Filter
806806
Name="Header Files"
807807
>
808+
<File
809+
RelativePath=".\include\Poco\Net\AbstractHTTPRequestHandler.h"
810+
>
811+
</File>
808812
<File
809813
RelativePath=".\include\Poco\Net\HTTPRequestHandler.h"
810814
>
@@ -833,10 +837,18 @@
833837
RelativePath=".\include\Poco\Net\HTTPServerRequest.h"
834838
>
835839
</File>
840+
<File
841+
RelativePath=".\include\Poco\Net\HTTPServerRequestImpl.h"
842+
>
843+
</File>
836844
<File
837845
RelativePath=".\include\Poco\Net\HTTPServerResponse.h"
838846
>
839847
</File>
848+
<File
849+
RelativePath=".\include\Poco\Net\HTTPServerResponseImpl.h"
850+
>
851+
</File>
840852
<File
841853
RelativePath=".\include\Poco\Net\HTTPServerSession.h"
842854
>
@@ -845,6 +857,10 @@
845857
<Filter
846858
Name="Source Files"
847859
>
860+
<File
861+
RelativePath=".\src\AbstractHTTPRequestHandler.cpp"
862+
>
863+
</File>
848864
<File
849865
RelativePath=".\src\HTTPRequestHandler.cpp"
850866
>
@@ -873,10 +889,18 @@
873889
RelativePath=".\src\HTTPServerRequest.cpp"
874890
>
875891
</File>
892+
<File
893+
RelativePath=".\src\HTTPServerRequestImpl.cpp"
894+
>
895+
</File>
876896
<File
877897
RelativePath=".\src\HTTPServerResponse.cpp"
878898
>
879899
</File>
900+
<File
901+
RelativePath=".\src\HTTPServerResponseImpl.cpp"
902+
>
903+
</File>
880904
<File
881905
RelativePath=".\src\HTTPServerSession.cpp"
882906
>
@@ -1157,6 +1181,10 @@
11571181
RelativePath=".\include\Poco\Net\RemoteSyslogChannel.h"
11581182
>
11591183
</File>
1184+
<File
1185+
RelativePath=".\include\Poco\Net\RemoteSyslogListener.h"
1186+
>
1187+
</File>
11601188
</Filter>
11611189
<Filter
11621190
Name="Source Files"
@@ -1165,6 +1193,10 @@
11651193
RelativePath=".\src\RemoteSyslogChannel.cpp"
11661194
>
11671195
</File>
1196+
<File
1197+
RelativePath=".\src\RemoteSyslogListener.cpp"
1198+
>
1199+
</File>
11681200
</Filter>
11691201
</Filter>
11701202
</Files>
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
//
2+
// AbstractHTTPRequestHandler.h
3+
//
4+
// $Id: //poco/Main/Net/include/Poco/Net/AbstractHTTPRequestHandler.h#2 $
5+
//
6+
// Library: Net
7+
// Package: HTTPServer
8+
// Module: AbstractHTTPRequestHandler
9+
//
10+
// Definition of the AbstractHTTPRequestHandler class.
11+
//
12+
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
13+
// and Contributors.
14+
//
15+
// Permission is hereby granted, free of charge, to any person or organization
16+
// obtaining a copy of the software and accompanying documentation covered by
17+
// this license (the "Software") to use, reproduce, display, distribute,
18+
// execute, and transmit the Software, and to prepare derivative works of the
19+
// Software, and to permit third-parties to whom the Software is furnished to
20+
// do so, all subject to the following:
21+
//
22+
// The copyright notices in the Software and this entire statement, including
23+
// the above license grant, this restriction and the following disclaimer,
24+
// must be included in all copies of the Software, in whole or in part, and
25+
// all derivative works of the Software, unless such copies or derivative
26+
// works are solely in the form of machine-executable object code generated by
27+
// a source language processor.
28+
//
29+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
32+
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
33+
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
34+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
35+
// DEALINGS IN THE SOFTWARE.
36+
//
37+
38+
39+
#ifndef Net_AbstractHTTPRequestHandler_INCLUDED
40+
#define Net_AbstractHTTPRequestHandler_INCLUDED
41+
42+
43+
#include "Poco/Net/HTTPRequestHandler.h"
44+
#include "Poco/Net/HTTPResponse.h"
45+
46+
47+
namespace Poco {
48+
namespace Net {
49+
50+
51+
class HTMLForm;
52+
53+
54+
class Net_API AbstractHTTPRequestHandler: public HTTPRequestHandler
55+
/// The abstract base class for AbstractHTTPRequestHandlers
56+
/// created by HTTPServer.
57+
///
58+
/// Derived classes must override the run() method.
59+
60+
/// Contrary to a HTTPRequestHandler, an AbstractHTTPRequestHandler
61+
/// stores request and response as member variables to avoid having
62+
/// to pass them around as method parameters. Additionally, a
63+
/// HTMLForm object is created for use by subclasses.
64+
///
65+
/// The run() method must perform the complete handling
66+
/// of the HTTP request connection. As soon as the run()
67+
/// method returns, the request handler object is destroyed.
68+
///
69+
/// A new AbstractHTTPRequestHandler object will be created for
70+
/// each new HTTP request that is received by the HTTPServer.
71+
{
72+
public:
73+
AbstractHTTPRequestHandler();
74+
/// Creates the AbstractHTTPRequestHandler.
75+
76+
virtual ~AbstractHTTPRequestHandler();
77+
/// Destroys the AbstractHTTPRequestHandler.
78+
79+
void handleRequest(HTTPServerRequest& request, HTTPServerResponse& response);
80+
/// This class implements some common behavior,
81+
/// before calling run() to actually handle the request:
82+
/// - save request and response objects;
83+
/// - call authorize();
84+
/// - if authorize() returns true call run(),
85+
/// else send 401 (Unauthorized) response.
86+
87+
HTTPServerRequest& request();
88+
/// Returns the request.
89+
90+
HTTPServerResponse& response();
91+
/// Returns the response.
92+
93+
HTMLForm& form();
94+
/// Returns a HTMLForm for the given request.
95+
/// The HTMLForm object is created when this
96+
/// member function is executed the first time.
97+
98+
void sendErrorResponse(HTTPResponse::HTTPStatus status, const std::string& message);
99+
/// Sends a HTML error page for the given status code.
100+
/// The given message is added to the page:
101+
/// <HTML>
102+
/// <HEAD>
103+
/// <TITLE>status - reason</TITLE>
104+
/// </HEAD>
105+
/// <BODY>
106+
/// <H1>status - reason</H1>
107+
/// <P>message</P>
108+
/// </BODY>
109+
/// </HTML>
110+
111+
protected:
112+
virtual void run() = 0;
113+
/// Must be overridden by subclasses.
114+
///
115+
/// Handles the given request.
116+
117+
virtual bool authenticate();
118+
/// Check authentication; returns true if okay, false if failed to authenticate.
119+
/// The default implementation always returns true.
120+
///
121+
/// Subclasses can override this member function to perform
122+
/// some form of client or request authentication before
123+
/// the request is actually handled.
124+
125+
private:
126+
HTTPServerRequest* _pRequest;
127+
HTTPServerResponse* _pResponse;
128+
HTMLForm* _pForm;
129+
};
130+
131+
132+
//
133+
// inlines
134+
//
135+
inline HTTPServerRequest& AbstractHTTPRequestHandler::request()
136+
{
137+
poco_check_ptr (_pRequest);
138+
139+
return *_pRequest;
140+
}
141+
142+
143+
inline HTTPServerResponse& AbstractHTTPRequestHandler::response()
144+
{
145+
poco_check_ptr (_pResponse);
146+
147+
return *_pResponse;
148+
}
149+
150+
151+
} } // namespace Poco::Net
152+
153+
154+
#endif // Net_AbstractHTTPRequestHandler_INCLUDED

Net/include/Poco/Net/FilePartSource.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// FilePartSource.h
33
//
4-
// $Id: //poco/Main/Net/include/Poco/Net/FilePartSource.h#2 $
4+
// $Id: //poco/Main/Net/include/Poco/Net/FilePartSource.h#3 $
55
//
66
// Library: Net
77
// Package: Messages
@@ -42,7 +42,7 @@
4242

4343
#include "Poco/Net/Net.h"
4444
#include "Poco/Net/PartSource.h"
45-
#include <fstream>
45+
#include "Poco/FileStream.h"
4646

4747

4848
namespace Poco {
@@ -77,8 +77,8 @@ class Net_API FilePartSource: public PartSource
7777
/// Returns the filename portion of the path.
7878

7979
private:
80-
std::ifstream _istr;
81-
std::string _filename;
80+
std::string _filename;
81+
Poco::FileInputStream _istr;
8282
};
8383

8484

0 commit comments

Comments
 (0)