DCL 4.0
Loading...
Searching...
No Matches
HttpServletContextEx Class Reference

#include <HttpServletEx.h>

Inheritance diagram for HttpServletContextEx:
HttpServletContext Object

Public Member Functions

StringWriterwriter ()
Public Member Functions inherited from Object
virtual String toString () const
virtual void destroy ()
String className () const
bool isInstanceOf (const std::type_info &typeinfo) const
virtual const std::type_info & typeInfo () const

Protected Member Functions

 HttpServletContextEx (const DCL_HTTP_SERVER_API *_SAPI, const DCL_HTTP_SERVLET_CONTEXT *_context, const String &_tempPath)
virtual ~HttpServletContextEx ()
void initRequest (size_t nMaxContentLength) __DCL_THROWS1(FormDataException *)
Protected Member Functions inherited from Object
virtual ~Object ()
 Object ()

Protected Attributes

StringWriter __responseBuf
Protected Attributes inherited from HttpServletContext
const DCL_HTTP_SERVER_API__SAPI
const DCL_HTTP_SERVLET_CONTEXT__context
String __contentType
unsigned int __statusCode
StringBuilder __responseHeaders
bool __headerFlushed

Friends

class HttpServletEx

Detailed Description

Definition at line 22 of file HttpServletEx.h.

Constructor & Destructor Documentation

◆ HttpServletContextEx()

HttpServletContextEx::HttpServletContextEx ( const DCL_HTTP_SERVER_API * _SAPI,
const DCL_HTTP_SERVLET_CONTEXT * _context,
const String & _tempPath )
protected

◆ ~HttpServletContextEx()

HttpServletContextEx::~HttpServletContextEx ( )
protectedvirtual

Definition at line 49 of file HttpServletEx.cpp.

50{
51}

Member Function Documentation

◆ initRequest()

void HttpServletContextEx::initRequest ( size_t nMaxContentLength)
protected

Definition at line 53 of file HttpServletEx.cpp.

56{
57 if (__context->pszQueryString)
59 ByteString(__context->pszQueryString),
60 __queryMap
61 );
62
63 HttpCookieDecoder::decode(getHttpHeader("Cookie"), __cookieMap);
64
65 if (methodNo() == HTTP_METHOD_POST) {
66 addHeader(HttpHeader(L"Cache-Control", L"no-cache"));
67
68 size_t nLength = contentLength();
69 if (nLength && (nMaxContentLength == 0 || nLength <= nMaxContentLength)) {
71 __context->pszContentType)) {
72 String str;
73 ByteBuffer* buf = ByteBuffer::create(nLength);
74 try {
75 size_t nRead = read(buf->data(), nLength);
76 buf->__dataLength = nRead;
77 *(buf->data() + buf->__dataLength) = L'\0';
78 ByteString s = buf;
79 buf->release();
80 __DCL_ASSERT(nRead == nLength);
81
83 }
84 catch(IOException* e) {
85 buf->release();
86 throw e;
87 }
88 }
89 else if (HttpFormDataDecoder::isValidType(__context->pszContentType)) {
90 // multipart-formdata
91 HttpInputStream input(this);
92#if 0
93 FileOutputStream output(__formFileMap.__tempDir + L"post.data", true);
94 Files::copy(input, output);
95#endif
96 HttpFormDataDecoder decoder;
97
98 decoder.decode(
99 input,
100 __context->pszContentType,
101 contentLength(),
102 __formMap,
103 __formFileMap
104 );
105#ifdef __DCL_DEBUG
106 if (!decoder.warnings().isEmpty()) {
107 __DCL_TRACE0(L"form-data decoding warnings\n");
108 __DCL_TRACE1(L"%ls\n", decoder.warnings().data());
109 }
110#endif
111 }
112 else {
113 __DCL_TRACE1(L"Unknown Content-Type[%ls]\n", contentType().data());
114 // unknown content-type
115 }
116 }
117
118 }
119}
@ HTTP_METHOD_POST
#define __DCL_TRACE0(psz)
Definition Object.h:375
#define __DCL_TRACE1(fmt, arg1)
Definition Object.h:376
#define __DCL_ASSERT(expr)
Definition Object.h:371
ByteBuffer * buf
static size_t copy(InputStream &_input, OutputStream &_output) __DCL_THROWS1(IOException *)
Definition Files.cpp:520
void decode(InputStream &_input, const char *_contentType, size_t _contentLength, ListedStringToStringArrayMap &_mapForm, HttpFormData &_mapFormFile) __DCL_THROWS1(HttpFormDataDecoderException *)
const String warnings() const
static void decode(const ByteString &_queryString, ListedStringToStringArrayMap &_results)
static bool isValidType(const char *_contentType)
const DCL_HTTP_SERVLET_CONTEXT * __context
Definition HttpServlet.h:74

◆ writer()

StringWriter & HttpServletContextEx::writer ( )

Definition at line 121 of file HttpServletEx.cpp.

122{
123 return __responseBuf;
124}
StringWriter __responseBuf

◆ HttpServletEx

friend class HttpServletEx
friend

Definition at line 46 of file HttpServletEx.h.

Member Data Documentation

◆ __responseBuf

StringWriter HttpServletContextEx::__responseBuf
protected

Definition at line 44 of file HttpServletEx.h.


The documentation for this class was generated from the following files: