porting rev.1894 to trunk

This commit is contained in:
Aleksandar Fabijanic
2012-07-27 02:01:39 +00:00
parent 348ca08e7a
commit 03ddca58f5
13 changed files with 168 additions and 46 deletions

View File

@@ -63,7 +63,13 @@ class Net_API HTTPFixedLengthStreamBuf: public HTTPBasicStreamBuf
public:
typedef HTTPBasicStreamBuf::openmode openmode;
HTTPFixedLengthStreamBuf(HTTPSession& session, std::streamsize length, openmode mode);
#if defined(POCO_HAVE_INT64)
typedef Poco::Int64 ContentLength;
#else
typedef std::streamsize ContentLength;
#endif
HTTPFixedLengthStreamBuf(HTTPSession& session, ContentLength length, openmode mode);
~HTTPFixedLengthStreamBuf();
protected:
@@ -72,8 +78,8 @@ protected:
private:
HTTPSession& _session;
std::streamsize _length;
std::streamsize _count;
ContentLength _length;
ContentLength _count;
};
@@ -81,7 +87,7 @@ class Net_API HTTPFixedLengthIOS: public virtual std::ios
/// The base class for HTTPFixedLengthInputStream.
{
public:
HTTPFixedLengthIOS(HTTPSession& session, std::streamsize length, HTTPFixedLengthStreamBuf::openmode mode);
HTTPFixedLengthIOS(HTTPSession& session, HTTPFixedLengthStreamBuf::ContentLength length, HTTPFixedLengthStreamBuf::openmode mode);
~HTTPFixedLengthIOS();
HTTPFixedLengthStreamBuf* rdbuf();
@@ -94,7 +100,7 @@ class Net_API HTTPFixedLengthInputStream: public HTTPFixedLengthIOS, public std:
/// This class is for internal use by HTTPSession only.
{
public:
HTTPFixedLengthInputStream(HTTPSession& session, std::streamsize length);
HTTPFixedLengthInputStream(HTTPSession& session, HTTPFixedLengthStreamBuf::ContentLength length);
~HTTPFixedLengthInputStream();
void* operator new(std::size_t size);
@@ -109,7 +115,7 @@ class Net_API HTTPFixedLengthOutputStream: public HTTPFixedLengthIOS, public std
/// This class is for internal use by HTTPSession only.
{
public:
HTTPFixedLengthOutputStream(HTTPSession& session, std::streamsize length);
HTTPFixedLengthOutputStream(HTTPSession& session, HTTPFixedLengthStreamBuf::ContentLength length);
~HTTPFixedLengthOutputStream();
void* operator new(std::size_t size);

View File

@@ -95,6 +95,9 @@ public:
/// always returns a 64-bit integer for content length.
#endif // defined(POCO_HAVE_INT64)
bool hasContentLength() const;
/// Returns true iff a Content-Length header is present.
void setTransferEncoding(const std::string& transferEncoding);
/// Sets the transfer encoding for this message.
///
@@ -192,6 +195,12 @@ inline const std::string& HTTPMessage::getVersion() const
}
inline bool HTTPMessage::hasContentLength() const
{
return has(CONTENT_LENGTH);
}
} } // namespace Poco::Net

View File

@@ -42,6 +42,7 @@
#include "Poco/Net/Net.h"
#include "Poco/Net/HTTPServerRequest.h"
#include "Poco/Net/HTTPServerResponseImpl.h"
#include "Poco/Net/SocketAddress.h"
#include "Poco/AutoPtr.h"
#include <istream>
@@ -64,7 +65,7 @@ class Net_API HTTPServerRequestImpl: public HTTPServerRequest
/// handleRequest() method of HTTPRequestHandler.
{
public:
HTTPServerRequestImpl(HTTPServerResponse& response, HTTPServerSession& session, HTTPServerParams* pParams);
HTTPServerRequestImpl(HTTPServerResponseImpl& response, HTTPServerSession& session, HTTPServerParams* pParams);
/// Creates the HTTPServerRequestImpl, using the
/// given HTTPServerSession.
@@ -105,7 +106,7 @@ protected:
static const std::string EXPECT;
private:
HTTPServerResponse& _response;
HTTPServerResponseImpl& _response;
HTTPServerSession& _session;
std::istream* _pStream;
Poco::AutoPtr<HTTPServerParams> _pParams;

View File

@@ -49,7 +49,7 @@ namespace Net {
class HTTPServerSession;
class HTTPCookie;
class HTTPServerRequestImpl;
class Net_API HTTPServerResponseImpl: public HTTPServerResponse
@@ -128,9 +128,15 @@ public:
bool sent() const;
/// Returns true if the response (header) has been sent.
protected:
void attachRequest(HTTPServerRequestImpl* pRequest);
private:
HTTPServerSession& _session;
HTTPServerRequestImpl* _pRequest;
std::ostream* _pStream;
friend class HTTPServerRequestImpl;
};
@@ -143,6 +149,12 @@ inline bool HTTPServerResponseImpl::sent() const
}
inline void HTTPServerResponseImpl::attachRequest(HTTPServerRequestImpl* pRequest)
{
_pRequest = pRequest;
}
} } // namespace Poco::Net