11#if __DCL_HAVE_ALLOC_DEBUG
12#undef __DCL_ALLOC_LEVEL
13#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
29#if __DCL_HAVE_THIS_FILE__
46 virtual Writer& write(
const wchar_t* _buf,
size_t _n)
57ReportErrorWriter::ReportErrorWriter(
65 __pfnReportError = pfnErrorReport;
66 __hErrorWriter = hErrorReport;
67 __pAltOutput = pAltOutput;
70Writer& ReportErrorWriter::write(
const wchar_t* _buf,
size_t _n)
76 __pAltOutput->write(_buf, _n);
82 __pfnReportError(__hErrorWriter, (
const char*)_buf, _n);
88HttpServletContext::HttpServletContext(
104HttpServletContext::~HttpServletContext()
108ByteString HttpServletContext::getHttpHeader(
117 ByteBuffer* buf = ByteBuffer::create(len);
118 if (!
__SAPI->pfnGetRequestHeader(
126 ByteBuffer::extend(buf, len);
128 __SAPI->pfnGetRequestHeader(
139 *(buf->data() + len) =
'\0';
140 buf->__dataLength = len;
147ByteString HttpServletContext::getCgiVariable(
156 ByteBuffer* buf = ByteBuffer::create(len);
157 if (!
__SAPI->pfnGetCgiVariable(
165 ByteBuffer::extend(buf, len);
167 __SAPI->pfnGetCgiVariable(
178 *(buf->data() + len) =
'\0';
179 buf->__dataLength = len;
186String HttpServletContext::getHttpHeader(
192 HttpServletContext::getHttpHeader(
193 AsciiEncoder::encode(_name, (
size_t)-1)
199 HttpServletContext::getHttpHeader((
const char*)
NULL)
204String HttpServletContext::getCgiVariable(
209 return UTF8Decoder::decode(
210 HttpServletContext::getCgiVariable(
211 UTF8Encoder::encode(_name, (
size_t)-1)
216 return UTF8Decoder::decode(
217 HttpServletContext::getCgiVariable((
const char*)
NULL)
222size_t HttpServletContext::read(
229 if (!__SAPI->pfnReadClient(
236 L
"HTTP Connection error"
243void HttpServletContext::setStatusCode(
unsigned int uHttpStatusCode)
248 setContentType(L
"text/html");
251void HttpServletContext::setContentType(
const wchar_t* _contentType,
const wchar_t* pszCharset )
266void HttpServletContext::addHeader(
const HttpHeader& httpHeader)
270 if (!httpHeader.
name().compareNoCase(L
"Content-Type"))
276void HttpServletContext::flushHeader()
292 __SAPI->pfnSendResponseHeader(
302void HttpServletContext::write(
310 if (!__headerFlushed)
314 if (!__SAPI->pfnWriteClient(
321 L
"http connection error"
330HttpServlet::HttpServlet()
337String HttpServlet::getIniFileName(
338 const wchar_t* _basename
345 basename = _basename;
349 size_t index = basename.lastIndexOf(
'.');
350 if (index != (
size_t) -1) {
352 basename = basename.left(index);
354 basename = basename + L
".ini";
359 if (!path.endsWith(L
"/")) {
362 path = path + basename;
370 if (!dir.endsWith(L
"/")) {
373 return dir + basename;
411 filename = filename.left(filename.lastIndexOf(L
'.')) + L
".dump.txt";
419 L
"Warning! dump file create fail. [%ls]: [%ls]\n",
435 DCLDebugSetThreadReport(
461 DCLDebugSetThreadReport(
466 if (!result && __debugFileOutput) {
467 delete __debugFileOutput;
468 __debugFileOutput =
NULL;
487 Writer* oldOutput = DCLDebugSetThreadReport(
512 oldOutput = DCLDebugSetThreadReport(
517 if (oldOutput != &output) {
518 __DCL_TRACE0(L
"Assertion Fail! 'oldOutput == &writer'\n");
521 if (__debugFileOutput) {
522 delete __debugFileOutput;
523 __debugFileOutput =
NULL;
544 DCLDebugSetThreadReport(
549 const void* pLastAllocPosition =
550 DCLDebugGetLastAllocPosition(
577 DCLDebugDumpThreadMemoryLeak(
584 DCLDebugSetThreadReport(
593#define __WSTR(s) s ? UTF8Decoder::decode(s, ByteString::length(s)) : String()
595String HttpServletContext::remoteAddr()
const
601unsigned int HttpServletContext::remotePort()
const
607String HttpServletContext::method()
const
613unsigned int HttpServletContext::methodNo()
const
619String HttpServletContext::path()
const
625String HttpServletContext::queryString()
const
631String HttpServletContext::contentType()
const
637size_t HttpServletContext::contentLength()
const
643String HttpServletContext::scriptFilename()
const
649String HttpServletContext::scriptData()
const
656const String& HttpServletContext::resContentType()
const
struct _DCL_HTTP_SERVLET_CONTEXT DCL_HTTP_SERVLET_CONTEXT
void(* DCLHttpWriteStream)(void *hWriter, const void *pvData, size_t uLength)
struct _DCL_HTTP_SERVER_API DCL_HTTP_SERVER_API
struct _DCL_HTTP_SERVLET_CONFIG DCL_HTTP_SERVLET_CONFIG
#define __DCL_TRACE0(psz)
#define __DCL_TRACE1(fmt, arg1)
#define __DCL_VERIFY(expr)
#define DECLARE_CLASSINFO(class_name)
#define __DCL_ASSERT(expr)
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
#define __DCL_TRACE2(fmt, arg1, arg2)
DCLCVAR const struct __endl endl
static String decode(const char *_mbs, size_t _mbslen=(size_t) -1)
String toStringAll() const
static String dirname(const String &_path)
static bool exists(const String &_path)
static String basename(const String &_path)
const DCL_HTTP_SERVLET_CONTEXT * __context
unsigned int __statusCode
const DCL_HTTP_SERVER_API * __SAPI
StringBuilder __responseHeaders
static bool __cleanup(HttpServlet *_servlet, void *hErrorReport)
virtual void onInitialize() __DCL_THROWS1(Exception *)
static bool __httpService(HttpServlet *_servlet, const DCL_HTTP_SERVLET_CONTEXT *_context, void *hErrorReport)
virtual void onHttpService(const DCL_HTTP_SERVLET_CONTEXT *pContext)=0__DCL_THROWS1(Exception *)
const DCL_HTTP_SERVER_API * __SAPI
const wchar_t * __moduleName
const wchar_t * __configPath
virtual void onCleanup() __DCL_THROWS1(Exception *)
const wchar_t * __tempPath
static bool __initialize(HttpServlet *_servlet, const DCL_HTTP_SERVLET_CONFIG *_config, void *hErrorReport)
virtual String toString() const
DCLHttpWriteStream pfnReportError
const wchar_t * pszConfigPath
const DCL_HTTP_SERVER_API * pSAPI
const wchar_t * pszModuleName
const wchar_t * pszTempPath
const char * pszRemoteAddr