mirror of
https://github.com/stefanocasazza/ULib.git
synced 2025-09-28 19:05:55 +08:00
add UHTTP:body plus sync
This commit is contained in:
parent
aefd65d717
commit
77eb3b1643
|
@ -710,7 +710,7 @@ static bool getDataFromPOST(bool bpeer)
|
|||
|
||||
UFlatBuffer fb, vec;
|
||||
|
||||
fb.setRoot(*UClientImage_Base::body);
|
||||
fb.setRoot(*UHTTP::body);
|
||||
fb.AsVector(vec);
|
||||
|
||||
*ap = vec.AsVectorGet<UString>(0);
|
||||
|
@ -1493,11 +1493,11 @@ static void POST_info()
|
|||
{
|
||||
U_TRACE_NO_PARAM(5, "::POST_info()")
|
||||
|
||||
U_INTERNAL_DUMP("UClientImage_Base::body(%u) = %#V", UClientImage_Base::body->size(), UClientImage_Base::body->rep)
|
||||
U_INTERNAL_DUMP("UHTTP::body(%u) = %#V", UHTTP::body->size(), UHTTP::body->rep)
|
||||
|
||||
UFlatBuffer fb, vec;
|
||||
|
||||
fb.setRoot(*UClientImage_Base::body);
|
||||
fb.setRoot(*UHTTP::body);
|
||||
fb.AsVector(vec);
|
||||
|
||||
*ap = vec.AsVectorGet<UString>(0);
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
# include <ulib/libevent/event.h>
|
||||
#endif
|
||||
|
||||
#include <sys/epoll.h>
|
||||
#ifndef _MSWINDOWS_
|
||||
# include <sys/epoll.h>
|
||||
#endif
|
||||
|
||||
#ifndef EPOLLIN
|
||||
#define EPOLLIN 0x0001
|
||||
|
|
|
@ -7396,7 +7396,7 @@ static void POST_info()
|
|||
U_INTERNAL_ASSERT_EQUALS(UServer_Base::bssl, false)
|
||||
|
||||
#ifdef USE_LIBZ
|
||||
if (UStringExt::isGzip(*UClientImage_Base::body)) *UClientImage_Base::body = UStringExt::gunzip(*UClientImage_Base::body);
|
||||
if (UStringExt::isGzip(*UHTTP::body)) *UHTTP::body = UStringExt::gunzip(*UHTTP::body);
|
||||
#endif
|
||||
|
||||
uint32_t end;
|
||||
|
@ -7583,7 +7583,7 @@ static void POST_roaming()
|
|||
U_TRACE_NO_PARAM(5, "::POST_roaming()")
|
||||
|
||||
#ifdef USE_LIBZ
|
||||
if (UStringExt::isGzip(*UClientImage_Base::body)) *UClientImage_Base::body = UStringExt::gunzip(*UClientImage_Base::body);
|
||||
if (UStringExt::isGzip(*UHTTP::body)) *UHTTP::body = UStringExt::gunzip(*UHTTP::body);
|
||||
#endif
|
||||
|
||||
uint32_t end;
|
||||
|
|
|
@ -24,12 +24,12 @@
|
|||
#define USP_PRINTF(fmt,args...) (UClientImage_Base::_buffer->snprintf(U_CONSTANT_TO_PARAM(fmt) , ##args),USP_PUTS_STRING(*UClientImage_Base::_buffer))
|
||||
#define USP_PRINTF_ADD(fmt,args...) UClientImage_Base::wbuffer->snprintf_add(U_CONSTANT_TO_PARAM(fmt) , ##args)
|
||||
|
||||
#define USP_JSON_REQUEST_PARSE(obj) JSON_parse(*UClientImage_Base::body,(obj))
|
||||
#define USP_JFIND_REQUEST(type,str) UValue::jfind(*UClientImage_Base::body,#type,U_CONSTANT_SIZE(#type),(str))
|
||||
#define USP_JSON_REQUEST_PARSE(obj) JSON_parse(*UHTTP::body,(obj))
|
||||
#define USP_JFIND_REQUEST(type,str) UValue::jfind(*UHTTP::body,#type,U_CONSTANT_SIZE(#type),(str))
|
||||
|
||||
#define USP_OBJ_JSON_stringify(obj) JSON_OBJ_stringify(*UClientImage_Base::wbuffer,(obj))
|
||||
|
||||
#define USP_SERIALIZE_OBJECT(class,obj) UFlatBuffer::toObject<class>(*UClientImage_Base::body,(obj))
|
||||
#define USP_SERIALIZE_OBJECT(class,obj) UFlatBuffer::toObject<class>(*UHTTP::body,(obj))
|
||||
|
||||
#define USP_XML_PUTS(string) \
|
||||
((void)UClientImage_Base::_encoded->reserve((string).size() * 4), \
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
|
||||
#include <ulib/container/hash_map.h>
|
||||
|
||||
#include <arpa/inet.h>
|
||||
#ifndef _MSWINDOWS_
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @see http://google.github.io/flatbuffers/index.html
|
||||
|
|
|
@ -172,6 +172,7 @@ public:
|
|||
static UFile* file;
|
||||
static UString* ext;
|
||||
static UString* etag;
|
||||
static UString* body;
|
||||
static UString* qcontent;
|
||||
static UString* pathname;
|
||||
static UString* rpathname;
|
||||
|
@ -204,7 +205,7 @@ public:
|
|||
static bool scanfHeaderRequest(const char* ptr, uint32_t size);
|
||||
static bool scanfHeaderResponse(const char* ptr, uint32_t size);
|
||||
static bool readHeaderResponse(USocket* socket, UString& buffer);
|
||||
static bool readBodyResponse(USocket* socket, UString* buffer, UString& body);
|
||||
static bool readBodyResponse(USocket* socket, UString* buffer, UString& lbody);
|
||||
|
||||
static UString getPathComponent(uint32_t index); // Returns the path element at the specified index
|
||||
|
||||
|
@ -429,8 +430,7 @@ public:
|
|||
U_TRACE_NO_PARAM(0, "UHTTP::setResponse()")
|
||||
|
||||
U_ASSERT(ext->empty())
|
||||
|
||||
UClientImage_Base::body->clear(); // clean body to avoid writev() in response...
|
||||
U_ASSERT(UClientImage_Base::body->empty())
|
||||
|
||||
handlerResponse();
|
||||
}
|
||||
|
@ -1401,7 +1401,7 @@ private:
|
|||
static int handlerREAD();
|
||||
static void processRequest();
|
||||
static void handlerResponse();
|
||||
static void setDynamicResponse(const UString& body, const UString& header = UString::getStringNull(), const UString& content_type = UString::getStringNull());
|
||||
static void setDynamicResponse(const UString& lbody, const UString& header = UString::getStringNull(), const UString& content_type = UString::getStringNull());
|
||||
|
||||
#ifndef U_LOG_DISABLE
|
||||
static int handlerREADWithLog()
|
||||
|
@ -1478,7 +1478,7 @@ private:
|
|||
static void checkArrayCompressData(UFileCacheData* ptr) U_NO_EXPORT;
|
||||
# endif
|
||||
|
||||
static inline bool compress(const UString& body) U_NO_EXPORT;
|
||||
static inline bool compress(UString& header, const UString& lbody) U_NO_EXPORT;
|
||||
static inline void setAcceptEncoding(const char* ptr, uint32_t len) U_NO_EXPORT;
|
||||
#endif
|
||||
|
||||
|
@ -1508,7 +1508,7 @@ private:
|
|||
static bool splitCGIOutput(const char*& ptr1, const char* ptr2) U_NO_EXPORT;
|
||||
static void setHeaderForCache(UFileCacheData* ptr, UString& data) U_NO_EXPORT;
|
||||
static void setResponseForRange(off_t start, off_t end, uint32_t header) U_NO_EXPORT;
|
||||
static bool readDataChunked(USocket* sk, UString* pbuffer, UString& body) U_NO_EXPORT;
|
||||
static bool readDataChunked(USocket* sk, UString* pbuffer, UString& lbody) U_NO_EXPORT;
|
||||
static void manageDataForCache(const UString& basename, const UString& suffix) U_NO_EXPORT;
|
||||
static bool checkDataSession(const UString& token, time_t expire, UString* data) U_NO_EXPORT;
|
||||
static void putDataInCache(const UString& path, const UString& fmt, UString& content) U_NO_EXPORT;
|
||||
|
|
|
@ -40,7 +40,7 @@ int UEchoPlugIn::handlerRequest()
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "UEchoPlugIn::handlerRequest()")
|
||||
|
||||
UClientImage_Base::body->clear();
|
||||
U_ASSERT(UClientImage_Base::body->empty())
|
||||
|
||||
UClientImage_Base::setRequestProcessed();
|
||||
UClientImage_Base::setNoHeaderForResponse();
|
||||
|
|
|
@ -338,9 +338,9 @@ int UFCGIPlugIn::handlerRequest()
|
|||
|
||||
// maybe we have some data to put on stdin of cgi process (POST)
|
||||
|
||||
U_INTERNAL_DUMP("UClientImage_Base::body(%u) = %V", UClientImage_Base::body->size(), UClientImage_Base::body->rep)
|
||||
U_INTERNAL_DUMP("UHTTP::body(%u) = %V", UHTTP::body->size(), UHTTP::body->rep)
|
||||
|
||||
size = UClientImage_Base::body->size();
|
||||
size = UHTTP::body->size();
|
||||
|
||||
if (size)
|
||||
{
|
||||
|
@ -357,7 +357,7 @@ int UFCGIPlugIn::handlerRequest()
|
|||
|
||||
if (size)
|
||||
{
|
||||
(void) request.append(*UClientImage_Base::body);
|
||||
(void) request.append(*UHTTP::body);
|
||||
|
||||
fill_FCGIBeginRequest(FCGI_STDIN, 0);
|
||||
|
||||
|
|
|
@ -1137,7 +1137,7 @@ int UNoDogPlugIn::handlerRequest()
|
|||
char policy;
|
||||
UFlatBuffer fb, vec;
|
||||
|
||||
fb.setRoot(*UClientImage_Base::body);
|
||||
fb.setRoot(*UHTTP::body);
|
||||
fb.AsVector(vec);
|
||||
|
||||
// $1 -> peer
|
||||
|
@ -1209,7 +1209,7 @@ int UNoDogPlugIn::handlerRequest()
|
|||
uint32_t n, ip_peer;
|
||||
UFlatBuffer fb, vec;
|
||||
|
||||
fb.setRoot(*UClientImage_Base::body);
|
||||
fb.setRoot(*UHTTP::body);
|
||||
fb.AsVector(vec);
|
||||
|
||||
n = vec.GetSize();
|
||||
|
|
|
@ -175,7 +175,7 @@ int USCGIPlugIn::handlerRequest()
|
|||
|
||||
request.snprintf(U_CONSTANT_TO_PARAM("%u:%v,"), environment.size(), environment.rep);
|
||||
|
||||
(void) request.append(*UClientImage_Base::body);
|
||||
(void) request.append(*UHTTP::body);
|
||||
|
||||
connection->prepareRequest(request);
|
||||
|
||||
|
|
|
@ -654,8 +654,8 @@ int UShibPlugIn::handlerRequest()
|
|||
U_ASSERT(U_HTTP_CTYPE_STRNEQ("application/x-www-form-urlencoded"))
|
||||
|
||||
UShibTarget::content_type = "application/x-www-form-urlencoded";
|
||||
UShibTarget::postdata_ptr = UClientImage_Base::body->data();
|
||||
UShibTarget::postdata_len = UClientImage_Base::body->size();
|
||||
UShibTarget::postdata_ptr = UHTTP::body->data();
|
||||
UShibTarget::postdata_len = UHTTP::body->size();
|
||||
|
||||
if (shib_handler()) mode = -1;
|
||||
else
|
||||
|
|
|
@ -87,7 +87,7 @@ int USoapPlugIn::handlerRequest()
|
|||
|
||||
bool bSendingFault;
|
||||
|
||||
UString body = soap_parser->processMessage(*UClientImage_Base::body, *URPCObject::dispatcher, bSendingFault),
|
||||
UString body = soap_parser->processMessage(*UHTTP::body, *URPCObject::dispatcher, bSendingFault),
|
||||
method = soap_parser->getMethodName();
|
||||
|
||||
U_SRV_LOG_WITH_ADDR("method %V process %s for", method.rep, (bSendingFault ? "failed" : "passed"));
|
||||
|
|
|
@ -1048,7 +1048,7 @@ int USSIPlugIn::handlerRequest()
|
|||
}
|
||||
else
|
||||
{
|
||||
U_INTERNAL_DUMP("UClientImage_Base::body(%u) = %V", UClientImage_Base::body->size(), UClientImage_Base::body->rep)
|
||||
U_INTERNAL_DUMP("UHTTP::body(%u) = %V", UHTTP::body->size(), UHTTP::body->rep)
|
||||
|
||||
U_ASSERT(UHTTP::isDataFromCache())
|
||||
U_INTERNAL_ASSERT_POINTER(UHTTP::file_data->array)
|
||||
|
@ -1061,8 +1061,8 @@ int USSIPlugIn::handlerRequest()
|
|||
(void) header->append(UHTTP::getDataFromCache(UHTTP::file_data->array, 1)); // NB: we must consider HTTP/2
|
||||
|
||||
*body = (UHTTP::isGETorHEAD() &&
|
||||
*UClientImage_Base::body
|
||||
? *UClientImage_Base::body
|
||||
*UHTTP::body
|
||||
? *UHTTP::body
|
||||
: UHTTP::getBodyFromCache());
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ int UTsaPlugIn::handlerRequest()
|
|||
|
||||
UString body;
|
||||
|
||||
if (command->execute(UClientImage_Base::body, &body) == false) UHTTP::setInternalError();
|
||||
if (command->execute(UHTTP::body, &body) == false) UHTTP::setInternalError();
|
||||
else
|
||||
{
|
||||
U_http_info.nResponseCode = HTTP_OK;
|
||||
|
|
|
@ -154,7 +154,7 @@ extern U_EXPORT bool runPYTHON();
|
|||
dict_set(py_environ, "wsgi.multithread", PyBool_FromLong(0));
|
||||
dict_set(py_environ, "wsgi.multiprocess", PyBool_FromLong(UServer_Base::isPreForked()));
|
||||
|
||||
if (*UClientImage_Base::body) dict_set(py_environ, "userver.req.content", PyByteArray_FromStringAndSize(U_STRING_TO_PARAM(*UClientImage_Base::body)));
|
||||
if (*UHTTP::body) dict_set(py_environ, "userver.req.content", PyByteArray_FromStringAndSize(U_STRING_TO_PARAM(*UHTTP::body)));
|
||||
|
||||
// call python
|
||||
|
||||
|
|
|
@ -77,8 +77,8 @@ static VALUE URUBY_io_rewind(VALUE obj, VALUE args)
|
|||
{
|
||||
U_TRACE(0, "URUBY_io_rewind(%llu,%llu)", obj, args)
|
||||
|
||||
post_readline_pos = UClientImage_Base::body->data();
|
||||
post_readline_watermark = post_readline_pos + UClientImage_Base::body->size();
|
||||
post_readline_pos = UHTTP::body->data();
|
||||
post_readline_watermark = post_readline_pos + UHTTP::body->size();
|
||||
|
||||
U_INTERNAL_DUMP("post_readline_pos = %p post_readline_watermark = %p", post_readline_pos, post_readline_watermark)
|
||||
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_db() { World::handlerForkSql(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
World::initOneResult();
|
||||
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_edb() { WorldNoSql::handlerForkElasticSearch(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
WorldNoSql::doOneQuery(WorldNoSql::handlerQueryElasticSearch);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_equery() { WorldNoSql::handlerForkElasticSearch(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
WorldNoSql::doQuery(WorldNoSql::handlerQueryElasticSearch);
|
||||
-->
|
||||
|
|
|
@ -23,9 +23,6 @@ static void usp_fork_eupdate()
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
World::doUpdateNoSql(WorldNoSql::handlerUpdateElasticSearch);
|
||||
-->
|
||||
|
|
|
@ -72,9 +72,6 @@ static void usp_fork_fortune()
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
Fortune::doQuery(handle_query);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_mdb() { WorldNoSql::handlerForkMongoDB(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
WorldNoSql::doOneQuery(WorldNoSql::handlerQueryMongoDB);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_mfortune() { FortuneNoSql::handlerForkMongoDB(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
Fortune::doQuery(FortuneNoSql::handlerQueryMongoDB);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_mquery() { WorldNoSql::handlerForkMongoDB(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
WorldNoSql::doQuery(WorldNoSql::handlerQueryMongoDB);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_mupdate() { WorldNoSql::handlerForkMongoDB(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
World::doUpdateNoSql(WorldNoSql::handlerUpdateMongoDB);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_query() { World::handlerForkSql(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
uint32_t i = 0, num_queries = UHTTP::getFormFirstNumericValue(1, 500);
|
||||
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_rdb() { WorldNoSql::handlerForkREDIS(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
WorldNoSql::doOneQuery(WorldNoSql::handlerQueryREDIS);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_rfortune() { FortuneNoSql::handlerForkREDIS(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
Fortune::doQuery(FortuneNoSql::handlerQueryREDIS);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_rquery() { WorldNoSql::handlerForkREDIS(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
WorldNoSql::doQuery(WorldNoSql::handlerQueryREDIS);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_rupdate() { WorldNoSql::handlerForkREDIS(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
World::doUpdateNoSql(WorldNoSql::handlerUpdateREDIS);
|
||||
-->
|
||||
|
|
|
@ -32,9 +32,6 @@ static void usp_fork_update()
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
uint32_t i = 0, num_queries = UHTTP::getFormFirstNumericValue(1, 500);
|
||||
|
||||
|
|
|
@ -467,7 +467,16 @@ public:
|
|||
|
||||
setDirectiveItem(directive, U_CONSTANT_SIZE("header"));
|
||||
|
||||
if (token.empty()) bhttp_header_empty = true;
|
||||
(void) output1.reserve(200U);
|
||||
|
||||
if (token.empty())
|
||||
{
|
||||
bhttp_header_empty = true;
|
||||
|
||||
# if !defined(U_SERVER_CAPTIVE_PORTAL) || !defined(ENABLE_THREAD)
|
||||
(void) output1.append(U_CONSTANT_TO_PARAM("\n\tU_http_info.endHeader = U_NOT_FOUND;\n"));
|
||||
# endif
|
||||
}
|
||||
else
|
||||
{
|
||||
// NB: we use insert because the possibility of UHTTP::callService() (see chat.usp)...
|
||||
|
@ -486,7 +495,6 @@ public:
|
|||
|
||||
U_ASSERT(encoded.isQuoted())
|
||||
|
||||
(void) output1.reserve(200U);
|
||||
(void) http_header.reserve(200U + encoded.size());
|
||||
|
||||
(void) http_header.snprintf(U_CONSTANT_TO_PARAM("\n\tU_ASSERT_EQUALS(UClientImage_Base::wbuffer->findEndHeader(),false)"
|
||||
|
|
|
@ -2605,7 +2605,7 @@ void UHTTP2::handlerResponse()
|
|||
if (U_http_info.nResponseCode == HTTP_NOT_IMPLEMENTED ||
|
||||
U_http_info.nResponseCode == HTTP_OPTIONS_RESPONSE)
|
||||
{
|
||||
UClientImage_Base::body->clear(); // clean body to avoid writev() in response...
|
||||
U_ASSERT(UClientImage_Base::body->empty())
|
||||
|
||||
UClientImage_Base::setCloseConnection();
|
||||
|
||||
|
@ -3100,7 +3100,7 @@ void UHTTP2::wrapRequest()
|
|||
bproxy = true;
|
||||
|
||||
uint32_t sz0 = pStream->headers.size(),
|
||||
body_sz = UClientImage_Base::body->size();
|
||||
body_sz = UHTTP::body->size();
|
||||
|
||||
U_DUMP("pStream->id = %u pStream->state = (%u, %s) pStream->headers(%u) = %V pStream->clength = %u pStream->body(%u) = %V",
|
||||
pStream->id, pStream->state, getStreamStatusDescription(), sz0, pStream->headers.rep, pStream->clength, body_sz, pStream->body.rep)
|
||||
|
@ -3149,10 +3149,10 @@ void UHTTP2::wrapRequest()
|
|||
|
||||
p0 += HTTP2_FRAME_HEADER_SIZE;
|
||||
|
||||
U_MEMCPY(p0, UClientImage_Base::body->data(), body_sz);
|
||||
p0 += body_sz;
|
||||
U_MEMCPY(p0, UHTTP::body->data(), body_sz);
|
||||
p0 += body_sz;
|
||||
|
||||
UClientImage_Base::body->clear();
|
||||
UHTTP::body->clear();
|
||||
}
|
||||
|
||||
UClientImage_Base::request->size_adjust(p0);
|
||||
|
@ -3560,7 +3560,7 @@ process_request:
|
|||
|
||||
U_http_info.clength = pStream->clength;
|
||||
|
||||
*UClientImage_Base::body = pStream->body;
|
||||
*UHTTP::body = pStream->body;
|
||||
|
||||
if (UHTTP::manageRequest() == U_PLUGIN_HANDLER_ERROR) goto err;
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ time_t UHTTP::htdigest_mtime;
|
|||
time_t UHTTP::htpasswd_mtime;
|
||||
UString* UHTTP::ext;
|
||||
UString* UHTTP::etag;
|
||||
UString* UHTTP::body;
|
||||
UString* UHTTP::geoip;
|
||||
UString* UHTTP::tmpdir;
|
||||
UString* UHTTP::htpasswd;
|
||||
|
@ -836,6 +837,7 @@ void UHTTP::init()
|
|||
|
||||
U_INTERNAL_ASSERT_EQUALS(ext, U_NULLPTR)
|
||||
U_INTERNAL_ASSERT_EQUALS(etag, U_NULLPTR)
|
||||
U_INTERNAL_ASSERT_EQUALS(body, U_NULLPTR)
|
||||
U_INTERNAL_ASSERT_EQUALS(file, U_NULLPTR)
|
||||
U_INTERNAL_ASSERT_EQUALS(pcmd, U_NULLPTR)
|
||||
U_INTERNAL_ASSERT_EQUALS(geoip, U_NULLPTR)
|
||||
|
@ -858,6 +860,7 @@ void UHTTP::init()
|
|||
|
||||
U_NEW_STRING(ext, UString);
|
||||
U_NEW_STRING(etag, UString);
|
||||
U_NEW_STRING(body, UString);
|
||||
U_NEW_STRING(geoip, UString(U_CAPACITY));
|
||||
U_NEW_STRING(tmpdir, UString(U_PATH_MAX));
|
||||
U_NEW_STRING(qcontent, UString);
|
||||
|
@ -1401,6 +1404,7 @@ void UHTTP::dtor()
|
|||
{
|
||||
U_DELETE(ext)
|
||||
U_DELETE(etag)
|
||||
U_DELETE(body)
|
||||
U_DELETE(file)
|
||||
U_DELETE(pcmd)
|
||||
U_DELETE(geoip)
|
||||
|
@ -2248,11 +2252,11 @@ U_NO_EXPORT inline bool UHTTP::checkDataChunked(UString* pbuffer)
|
|||
U_RETURN(false);
|
||||
}
|
||||
|
||||
U_NO_EXPORT bool UHTTP::readDataChunked(USocket* sk, UString* pbuffer, UString& body)
|
||||
U_NO_EXPORT bool UHTTP::readDataChunked(USocket* sk, UString* pbuffer, UString& lbody)
|
||||
{
|
||||
U_TRACE(0, "UHTTP::readDataChunked(%p,%V,%V)", sk, pbuffer->rep, body.rep)
|
||||
U_TRACE(0, "UHTTP::readDataChunked(%p,%V,%V)", sk, pbuffer->rep, lbody.rep)
|
||||
|
||||
U_ASSERT(body.empty())
|
||||
U_ASSERT(lbody.empty())
|
||||
|
||||
if (checkDataChunked(pbuffer))
|
||||
{
|
||||
|
@ -2323,9 +2327,9 @@ U_NO_EXPORT bool UHTTP::readDataChunked(USocket* sk, UString* pbuffer, UString&
|
|||
inp = ptr + U_http_info.endHeader;
|
||||
end = ptr + (len = pbuffer->size());
|
||||
|
||||
body.setBuffer(len - U_http_info.endHeader);
|
||||
lbody.setBuffer(len - U_http_info.endHeader);
|
||||
|
||||
out = body.data();
|
||||
out = lbody.data();
|
||||
|
||||
loop: U_INTERNAL_DUMP("inp = %.20S", inp) // Decode the hexadecimal chunk size into an understandable number
|
||||
|
||||
|
@ -2351,13 +2355,13 @@ loop: U_INTERNAL_DUMP("inp = %.20S", inp) // Decode the hexadecimal chunk size i
|
|||
|
||||
if (chunkSize == 0)
|
||||
{
|
||||
size = body.distance(out);
|
||||
size = lbody.distance(out);
|
||||
|
||||
if (size)
|
||||
{
|
||||
body.size_adjust(size);
|
||||
lbody.size_adjust(size);
|
||||
|
||||
U_INTERNAL_DUMP("body(%u) = %V", size, body.rep)
|
||||
U_INTERNAL_DUMP("lbody(%u) = %V", size, lbody.rep)
|
||||
|
||||
len = pbuffer->distance(inp) + U_CONSTANT_SIZE(U_CRLF2);
|
||||
|
||||
|
@ -2414,7 +2418,6 @@ U_NO_EXPORT bool UHTTP::readBodyRequest()
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "UHTTP::readBodyRequest()")
|
||||
|
||||
U_ASSERT(UClientImage_Base::body->empty())
|
||||
U_INTERNAL_ASSERT_EQUALS(U_line_terminator_len, 2)
|
||||
|
||||
uint32_t body_byte_read = UClientImage_Base::request->size() - U_http_info.endHeader;
|
||||
|
@ -2477,7 +2480,7 @@ U_NO_EXPORT bool UHTTP::readBodyRequest()
|
|||
U_RETURN(false);
|
||||
}
|
||||
|
||||
if (readDataChunked(UServer_Base::csocket, UClientImage_Base::request, *UClientImage_Base::body)) U_RETURN(true);
|
||||
if (readDataChunked(UServer_Base::csocket, UClientImage_Base::request, *body)) U_RETURN(true);
|
||||
|
||||
U_INTERNAL_DUMP("U_http_data_chunked = %b", U_http_data_chunked)
|
||||
|
||||
|
@ -2496,18 +2499,18 @@ U_NO_EXPORT bool UHTTP::readBodyRequest()
|
|||
|
||||
U_INTERNAL_ASSERT_MAJOR(U_http_info.clength, 0)
|
||||
|
||||
*UClientImage_Base::body = UClientImage_Base::request->substr(U_http_info.endHeader, U_http_info.clength);
|
||||
*body = UClientImage_Base::request->substr(U_http_info.endHeader, U_http_info.clength);
|
||||
|
||||
UClientImage_Base::setRequestNoCache();
|
||||
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
bool UHTTP::readBodyResponse(USocket* sk, UString* pbuffer, UString& body)
|
||||
bool UHTTP::readBodyResponse(USocket* sk, UString* pbuffer, UString& lbody)
|
||||
{
|
||||
U_TRACE(0, "UHTTP::readBodyResponse(%p,%V,%V)", sk, pbuffer->rep, body.rep)
|
||||
U_TRACE(0, "UHTTP::readBodyResponse(%p,%V,%V)", sk, pbuffer->rep, lbody.rep)
|
||||
|
||||
U_ASSERT(body.empty())
|
||||
U_ASSERT(lbody.empty())
|
||||
U_INTERNAL_ASSERT_EQUALS(U_line_terminator_len, 2)
|
||||
U_INTERNAL_ASSERT_DIFFERS(U_http_info.endHeader, 0)
|
||||
|
||||
|
@ -2529,12 +2532,12 @@ bool UHTTP::readBodyResponse(USocket* sk, UString* pbuffer, UString& body)
|
|||
}
|
||||
}
|
||||
|
||||
body = pbuffer->substr(U_http_info.endHeader, U_http_info.clength);
|
||||
lbody = pbuffer->substr(U_http_info.endHeader, U_http_info.clength);
|
||||
|
||||
U_RETURN(true);
|
||||
}
|
||||
|
||||
if (readDataChunked(sk, pbuffer, body)) U_RETURN(true);
|
||||
if (readDataChunked(sk, pbuffer, lbody)) U_RETURN(true);
|
||||
|
||||
U_RETURN(false);
|
||||
}
|
||||
|
@ -4015,7 +4018,7 @@ int UHTTP::handlerREAD()
|
|||
|
||||
UClientImage_Base::setRequestProcessed();
|
||||
|
||||
UClientImage_Base::body->clear(); // clean body to avoid writev() in response...
|
||||
U_ASSERT(UClientImage_Base::body->empty())
|
||||
|
||||
(void) UClientImage_Base::wbuffer->assign(U_CONSTANT_TO_PARAM("Allow: "
|
||||
"GET, HEAD, POST, PUT, DELETE, OPTIONS, " // request methods
|
||||
|
@ -4092,7 +4095,7 @@ int UHTTP::handlerREAD()
|
|||
|
||||
U_SRV_LOG("we strike back sending gzip bomb...", 0);
|
||||
|
||||
UClientImage_Base::body->clear();
|
||||
U_ASSERT(UClientImage_Base::body->empty())
|
||||
|
||||
U_http_info.nResponseCode = HTTP_OK;
|
||||
|
||||
|
@ -4791,9 +4794,7 @@ void UHTTP::writeUploadData(const char* ptr, uint32_t sz)
|
|||
|
||||
(void) dest.append(basename);
|
||||
|
||||
if (UFile::writeTo(dest, *UClientImage_Base::body) == false) U_http_info.nResponseCode = HTTP_INTERNAL_ERROR;
|
||||
|
||||
UClientImage_Base::body->clear(); // clean body to avoid writev() in response...
|
||||
if (UFile::writeTo(dest, *body) == false) U_http_info.nResponseCode = HTTP_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
bool UHTTP::getFileInCache(const char* name, uint32_t len)
|
||||
|
@ -4832,15 +4833,15 @@ U_NO_EXPORT inline void UHTTP::resetFileCache()
|
|||
}
|
||||
|
||||
#if defined(USE_LIBZ) || defined(USE_LIBBROTLI)
|
||||
U_NO_EXPORT inline bool UHTTP::compress(const UString& body)
|
||||
U_NO_EXPORT inline bool UHTTP::compress(UString& header, const UString& lbody)
|
||||
{
|
||||
U_TRACE(0, "UHTTP::compress(%V)", body.rep)
|
||||
U_TRACE(0, "UHTTP::compress(%V,%V)", header.rep, lbody.rep)
|
||||
|
||||
char* ptr = ext->data();
|
||||
char* ptr = header.data();
|
||||
|
||||
#ifdef USE_LIBBROTLI
|
||||
if (U_http_is_accept_brotli &&
|
||||
(*UClientImage_Base::body = UStringExt::brotli(body, (U_PARALLELIZATION_CHILD ? BROTLI_MAX_QUALITY : brotli_level_for_dynamic_content))))
|
||||
(*UClientImage_Base::body = UStringExt::brotli(lbody, (U_PARALLELIZATION_CHILD ? BROTLI_MAX_QUALITY : brotli_level_for_dynamic_content))))
|
||||
{
|
||||
# ifndef U_CACHE_REQUEST_DISABLE
|
||||
is_response_compressed = 2; // brotli
|
||||
|
@ -4851,7 +4852,7 @@ U_NO_EXPORT inline bool UHTTP::compress(const UString& body)
|
|||
u_put_unalignedp32(ptr+16, U_MULTICHAR_CONSTANT32(':',' ','b','r'));
|
||||
u_put_unalignedp16(ptr+20, U_MULTICHAR_CONSTANT16('\r','\n'));
|
||||
|
||||
ext->rep->_length = U_CONSTANT_SIZE("Content-Encoding: br\r\n");
|
||||
header.rep->_length = U_CONSTANT_SIZE("Content-Encoding: br\r\n");
|
||||
|
||||
U_SRV_LOG("dynamic response: %u bytes - (%u%%) brotli compression ratio", UClientImage_Base::body->size(), 100-UStringExt::ratio);
|
||||
|
||||
|
@ -4861,7 +4862,7 @@ U_NO_EXPORT inline bool UHTTP::compress(const UString& body)
|
|||
|
||||
#ifdef USE_LIBZ
|
||||
if (U_http_is_accept_gzip &&
|
||||
(*UClientImage_Base::body = UStringExt::deflate(body, (U_PARALLELIZATION_CHILD ? 0 : gzip_level_for_dynamic_content))))
|
||||
(*UClientImage_Base::body = UStringExt::deflate(lbody, (U_PARALLELIZATION_CHILD ? 0 : gzip_level_for_dynamic_content))))
|
||||
{
|
||||
# ifndef U_CACHE_REQUEST_DISABLE
|
||||
is_response_compressed = 1; // gzip
|
||||
|
@ -4871,7 +4872,7 @@ U_NO_EXPORT inline bool UHTTP::compress(const UString& body)
|
|||
u_put_unalignedp64(ptr+8, U_MULTICHAR_CONSTANT64('E','n','c','o','d','i','n','g'));
|
||||
u_put_unalignedp64(ptr+16, U_MULTICHAR_CONSTANT64(':',' ','g','z','i','p','\r','\n'));
|
||||
|
||||
ext->rep->_length = U_CONSTANT_SIZE("Content-Encoding: gzip\r\n");
|
||||
header.rep->_length = U_CONSTANT_SIZE("Content-Encoding: gzip\r\n");
|
||||
|
||||
U_SRV_LOG("dynamic response: %u bytes - (%u%%) %s compression ratio", UClientImage_Base::body->size(), 100-UStringExt::ratio, UStringExt::deflate_agent);
|
||||
|
||||
|
@ -4883,18 +4884,18 @@ U_NO_EXPORT inline bool UHTTP::compress(const UString& body)
|
|||
}
|
||||
#endif
|
||||
|
||||
void UHTTP::setDynamicResponse(const UString& body, const UString& header, const UString& content_type)
|
||||
void UHTTP::setDynamicResponse(const UString& lbody, const UString& header, const UString& content_type)
|
||||
{
|
||||
U_TRACE(0, "UHTTP::setDynamicResponse(%V,%V,%V)", body.rep, header.rep, content_type.rep)
|
||||
U_TRACE(0, "UHTTP::setDynamicResponse(%V,%V,%V)", lbody.rep, header.rep, content_type.rep)
|
||||
|
||||
ext->setBuffer(U_CAPACITY);
|
||||
|
||||
#if defined(USE_LIBZ) || defined(USE_LIBBROTLI)
|
||||
if (checkForCompression(body.size()) == false ||
|
||||
compress(body) == false)
|
||||
if (checkForCompression(lbody.size()) == false ||
|
||||
compress(*ext, lbody) == false)
|
||||
#endif
|
||||
{
|
||||
*UClientImage_Base::body = body;
|
||||
*UClientImage_Base::body = lbody;
|
||||
}
|
||||
|
||||
if (header)
|
||||
|
@ -4963,7 +4964,7 @@ void UHTTP::processRequest()
|
|||
{
|
||||
U_INTERNAL_DUMP("U_http_info.clength = %u", U_http_info.clength)
|
||||
|
||||
if (*UClientImage_Base::body) writeUploadData(ptr, sz);
|
||||
if (*body) writeUploadData(ptr, sz);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -5254,7 +5255,8 @@ void UHTTP::setEndRequestProcessing()
|
|||
{
|
||||
U_TRACE_NO_PARAM(0, "UHTTP::setEndRequestProcessing()")
|
||||
|
||||
ext->clear();
|
||||
ext->clear();
|
||||
body->clear();
|
||||
|
||||
#ifdef U_ALIAS
|
||||
alias->clear();
|
||||
|
@ -6438,12 +6440,12 @@ uint32_t UHTTP::processForm()
|
|||
// Content-Type: application/x-www-form-urlencoded OR multipart/form-data
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
if (U_HTTP_CTYPE_MEMEQ("application/x-www-form-urlencoded")) tmp = *UClientImage_Base::body;
|
||||
if (U_HTTP_CTYPE_MEMEQ("application/x-www-form-urlencoded")) tmp = *body;
|
||||
else
|
||||
{
|
||||
// multipart/form-data (FILE UPLOAD)
|
||||
|
||||
if (*UClientImage_Base::body &&
|
||||
if (*body &&
|
||||
U_HTTP_CTYPE_MEMEQ("multipart/form-data"))
|
||||
{
|
||||
// create temporary directory with files uploaded...
|
||||
|
@ -6451,7 +6453,7 @@ uint32_t UHTTP::processForm()
|
|||
tmpdir->snprintf(U_CONSTANT_TO_PARAM("%s/formXXXXXX"), u_tmpdir);
|
||||
|
||||
if (UFile::mkdtemp(*tmpdir) &&
|
||||
formMulti->init(*UClientImage_Base::body))
|
||||
formMulti->init(*body))
|
||||
{
|
||||
UMimeEntity* item;
|
||||
const char* ptr = tmpdir->data();
|
||||
|
@ -6849,7 +6851,7 @@ void UHTTP::setResponse(const UString& content_type, UString* pbody)
|
|||
|
||||
if (pbody == U_NULLPTR)
|
||||
{
|
||||
UClientImage_Base::body->clear(); // clean body to avoid writev() in response...
|
||||
U_ASSERT(UClientImage_Base::body->empty())
|
||||
|
||||
pbody = UClientImage_Base::body;
|
||||
}
|
||||
|
@ -6988,6 +6990,8 @@ void UHTTP::setRedirectResponse(int mode, const char* ptr_location, uint32_t len
|
|||
|
||||
if ((mode & NO_BODY) != 0)
|
||||
{
|
||||
U_ASSERT(UClientImage_Base::body->empty())
|
||||
|
||||
sz = tmp.size();
|
||||
|
||||
uint32_t sz1 = sz + U_CONSTANT_SIZE("Content-Length: 0\r\n\r\n");
|
||||
|
@ -7005,8 +7009,6 @@ void UHTTP::setRedirectResponse(int mode, const char* ptr_location, uint32_t len
|
|||
|
||||
ext->size_adjust_constant(sz1);
|
||||
|
||||
UClientImage_Base::body->clear(); // clean body to avoid writev() in response...
|
||||
|
||||
handlerResponse();
|
||||
}
|
||||
else
|
||||
|
@ -7025,17 +7027,17 @@ void UHTTP::setRedirectResponse(int mode, const char* ptr_location, uint32_t len
|
|||
}
|
||||
|
||||
const char* status = getStatusDescription(&sz);
|
||||
UString body(500U + len_location), content_type(U_CAPACITY);
|
||||
UString lbody(500U + len_location), content_type(U_CAPACITY);
|
||||
|
||||
body.snprintf(U_CONSTANT_TO_PARAM(U_STR_FMR_BODY),
|
||||
U_http_info.nResponseCode, sz, status,
|
||||
sz, status,
|
||||
len, msg);
|
||||
lbody.snprintf(U_CONSTANT_TO_PARAM(U_STR_FMR_BODY),
|
||||
U_http_info.nResponseCode, sz, status,
|
||||
sz, status,
|
||||
len, msg);
|
||||
|
||||
(void) content_type.assign(U_CONSTANT_TO_PARAM(U_CTYPE_HTML "\r\n"));
|
||||
(void) content_type.append(tmp);
|
||||
|
||||
setResponse(content_type, &body);
|
||||
setResponse(content_type, &lbody);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7058,14 +7060,14 @@ void UHTTP::setErrorResponse(const UString& content_type, int code, const char*
|
|||
fmt_size = U_CONSTANT_SIZE("Your browser sent a request that this server could not understand");
|
||||
}
|
||||
|
||||
UString body;
|
||||
UString lbody;
|
||||
|
||||
UHTTP::UFileCacheData* ptr_file_data = getFileCachePointerVar(U_CONSTANT_TO_PARAM("ErrorDocument/%u.html"), (U_http_info.nResponseCode = code));
|
||||
|
||||
if (ptr_file_data &&
|
||||
ptr_file_data->array != U_NULLPTR)
|
||||
{
|
||||
body = (*ptr_file_data->array)[0];
|
||||
lbody = (*ptr_file_data->array)[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -7089,7 +7091,7 @@ void UHTTP::setErrorResponse(const UString& content_type, int code, const char*
|
|||
sz, status,
|
||||
len, buffer);
|
||||
|
||||
body = x;
|
||||
lbody = x;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -7100,11 +7102,11 @@ void UHTTP::setErrorResponse(const UString& content_type, int code, const char*
|
|||
sz, status,
|
||||
fmt_size, fmt);
|
||||
|
||||
body = x;
|
||||
lbody = x;
|
||||
}
|
||||
}
|
||||
|
||||
setResponse(content_type, &body);
|
||||
setResponse(content_type, &lbody);
|
||||
}
|
||||
|
||||
void UHTTP::setUnAuthorized()
|
||||
|
@ -7337,38 +7339,53 @@ void UHTTP::setDynamicResponse()
|
|||
{
|
||||
U_TRACE_NO_PARAM(1, "UHTTP::setDynamicResponse()")
|
||||
|
||||
U_INTERNAL_DUMP("U_http_info.endHeader = %u U_http_content_type_len = %u mime_index(%d) = %C U_http_usp_flag = %u UClientImage_Base::wbuffer(%u) = %V",
|
||||
U_http_info.endHeader, U_http_content_type_len, mime_index, mime_index, U_http_usp_flag, UClientImage_Base::wbuffer->size(), UClientImage_Base::wbuffer->rep)
|
||||
U_INTERNAL_DUMP("U_http_info.endHeader = %d U_http_content_type_len = %u mime_index(%d) = %C U_http_usp_flag = %u UClientImage_Base::wbuffer(%u) = %V",
|
||||
(int32_t)U_http_info.endHeader, U_http_content_type_len, mime_index, mime_index, U_http_usp_flag, UClientImage_Base::wbuffer->size(), UClientImage_Base::wbuffer->rep)
|
||||
|
||||
U_INTERNAL_ASSERT_MAJOR(U_http_info.nResponseCode, 0)
|
||||
|
||||
char* ptr;
|
||||
uint32_t clength;
|
||||
bool bcontent_type; // NB: if false we assume that we don't have a HTTP content-type header...
|
||||
const char* pEndHeader;
|
||||
bool bcontent_type = false; // NB: if false we assume that we don't have a HTTP content-type header...
|
||||
uint32_t clength = UClientImage_Base::wbuffer->size();
|
||||
|
||||
#if !defined(USE_LIBZ) && !defined(USE_LIBBROTLI)
|
||||
bool bcompress = false;
|
||||
#else
|
||||
bool bcompress = checkForCompression(clength);
|
||||
#endif
|
||||
|
||||
ext->setBuffer(U_CAPACITY);
|
||||
|
||||
if (U_http_info.endHeader)
|
||||
{
|
||||
if ((int32_t)U_http_info.endHeader < 0)
|
||||
if ((int32_t)U_http_info.endHeader >= 0) bcontent_type = false;
|
||||
else
|
||||
{
|
||||
if (U_http_info.endHeader == U_NOT_FOUND)
|
||||
{
|
||||
U_ASSERT(UClientImage_Base::body->empty())
|
||||
|
||||
UClientImage_Base::setRequestProcessed();
|
||||
|
||||
UClientImage_Base::setHeaderForResponse(6+29+2+12+2); // Date: Wed, 20 Jun 2012 11:43:17 GMT\r\nServer: ULib\r\n
|
||||
|
||||
setStatusDescription();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bcontent_type = true;
|
||||
|
||||
U_http_info.endHeader = -U_http_info.endHeader;
|
||||
}
|
||||
|
||||
clength = UClientImage_Base::wbuffer->size();
|
||||
|
||||
U_INTERNAL_ASSERT(clength >= U_http_info.endHeader)
|
||||
|
||||
clength -= U_http_info.endHeader;
|
||||
|
||||
if (clength == 0) goto no_response;
|
||||
if (clength == 0)
|
||||
{
|
||||
U_ASSERT(UClientImage_Base::body->empty())
|
||||
|
||||
goto end;
|
||||
}
|
||||
|
||||
ext->setBuffer(U_CAPACITY);
|
||||
|
||||
pEndHeader = UClientImage_Base::wbuffer->data();
|
||||
|
||||
|
@ -7387,39 +7404,46 @@ void UHTTP::setDynamicResponse()
|
|||
}
|
||||
# endif
|
||||
|
||||
if (bcompress == false)
|
||||
{
|
||||
(void) UClientImage_Base::body->replace(pEndHeader + U_http_info.endHeader, clength);
|
||||
# if defined(USE_LIBZ) || defined(USE_LIBBROTLI)
|
||||
if (checkForCompression(clength) == false)
|
||||
# endif
|
||||
{
|
||||
(void) UClientImage_Base::body->replace(pEndHeader + U_http_info.endHeader, clength);
|
||||
|
||||
goto next;
|
||||
}
|
||||
goto next;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
clength = UClientImage_Base::wbuffer->size();
|
||||
|
||||
if (clength == 0)
|
||||
{
|
||||
no_response:
|
||||
UClientImage_Base::body->clear(); // clean body to avoid writev() in response...
|
||||
U_ASSERT(UClientImage_Base::body->empty())
|
||||
|
||||
handlerResponse();
|
||||
|
||||
return;
|
||||
goto end;
|
||||
}
|
||||
|
||||
bcontent_type = false;
|
||||
|
||||
pEndHeader = U_NULLPTR;
|
||||
|
||||
if (bcompress == false)
|
||||
{
|
||||
*UClientImage_Base::body = *UClientImage_Base::wbuffer;
|
||||
ext->setBuffer(U_CAPACITY);
|
||||
|
||||
goto next;
|
||||
}
|
||||
# if defined(USE_LIBZ) || defined(USE_LIBBROTLI)
|
||||
if (checkForCompression(clength) == false)
|
||||
# endif
|
||||
{
|
||||
*UClientImage_Base::body = *UClientImage_Base::wbuffer;
|
||||
|
||||
goto next;
|
||||
}
|
||||
}
|
||||
|
||||
U_INTERNAL_ASSERT(bcompress)
|
||||
U_ASSERT(checkForCompression(clength))
|
||||
|
||||
#if defined(USE_LIBZ) || defined(USE_LIBBROTLI)
|
||||
if (compress(UClientImage_Base::wbuffer->substr(U_http_info.endHeader, clength))) clength = UClientImage_Base::body->size();
|
||||
if (compress(*ext, UClientImage_Base::wbuffer->substr(U_http_info.endHeader, clength))) clength = UClientImage_Base::body->size();
|
||||
else
|
||||
{
|
||||
U_INTERNAL_ASSERT_MAJOR(clength, 0)
|
||||
|
@ -7430,6 +7454,8 @@ no_response:
|
|||
#endif
|
||||
|
||||
next:
|
||||
U_ASSERT_MAJOR(ext->space(), 0)
|
||||
|
||||
ptr = ext->pend();
|
||||
|
||||
if (bcontent_type == false)
|
||||
|
@ -7471,6 +7497,7 @@ next:
|
|||
|
||||
addContentLengthToHeader(*ext, ptr, clength, pEndHeader);
|
||||
|
||||
end:
|
||||
handlerResponse();
|
||||
}
|
||||
|
||||
|
@ -9222,9 +9249,9 @@ U_NO_EXPORT void UHTTP::processFileCache()
|
|||
range_size = file_data->size;
|
||||
range_start = 0;
|
||||
|
||||
UString body = getBodyFromCache();
|
||||
UString lbody = getBodyFromCache();
|
||||
|
||||
if (body.empty())
|
||||
if (lbody.empty())
|
||||
{
|
||||
// NB: we can't service the content of file directly from cache, the status must be 'file exist and need to be processed'...
|
||||
|
||||
|
@ -9233,15 +9260,15 @@ U_NO_EXPORT void UHTTP::processFileCache()
|
|||
return;
|
||||
}
|
||||
|
||||
U_INTERNAL_ASSERT_EQUALS(body.size(), range_size)
|
||||
U_INTERNAL_ASSERT_EQUALS(lbody.size(), range_size)
|
||||
|
||||
*ext = getHeaderFromCache();
|
||||
|
||||
if (checkGetRequestForRange(body.data()) == U_PARTIAL)
|
||||
if (checkGetRequestForRange(lbody.data()) == U_PARTIAL)
|
||||
{
|
||||
U_ASSERT_EQUALS(isSizeForSendfile(range_size), false)
|
||||
|
||||
*UClientImage_Base::body = body.substr(range_start, range_size);
|
||||
*UClientImage_Base::body = lbody.substr(range_start, range_size);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -9785,7 +9812,7 @@ bool UHTTP::getCGIEnvironment(UString& environment, int type)
|
|||
|
||||
buffer.snprintf_add(U_CONSTANT_TO_PARAM("CONTENT_LENGTH=%u\n"
|
||||
"REQUEST_METHOD=%.*s\n"),
|
||||
UClientImage_Base::body->size(),
|
||||
body->size(),
|
||||
U_HTTP_METHOD_TO_TRACE);
|
||||
|
||||
if ((type & U_PHP) == 0) buffer.snprintf_add(U_CONSTANT_TO_PARAM("SCRIPT_NAME=%.*s\n"), sz, ptr);
|
||||
|
@ -10473,8 +10500,6 @@ loop:
|
|||
{
|
||||
// NB: we assume to have no content without HTTP headers...
|
||||
|
||||
UClientImage_Base::body->clear();
|
||||
|
||||
setResponse();
|
||||
|
||||
U_RETURN(true);
|
||||
|
@ -10679,7 +10704,7 @@ loop:
|
|||
if (http_response)
|
||||
{
|
||||
noparse:
|
||||
UClientImage_Base::body->clear();
|
||||
U_ASSERT(UClientImage_Base::body->empty())
|
||||
|
||||
UClientImage_Base::setNoHeaderForResponse();
|
||||
|
||||
|
@ -10695,7 +10720,7 @@ noparse:
|
|||
{
|
||||
// NB: we assume to have no content with some HTTP headers...
|
||||
|
||||
UClientImage_Base::body->clear();
|
||||
U_ASSERT(UClientImage_Base::body->empty())
|
||||
|
||||
// NB: we use the var 'set_cookie' for opportunism within handlerResponse()...
|
||||
|
||||
|
@ -10750,7 +10775,7 @@ bool UHTTP::processCGIRequest(UCommand* cmd, UHTTP::ucgi* cgi)
|
|||
|
||||
if (fd_stderr == 0) fd_stderr = UServices::getDevNull("/tmp/processCGIRequest.err");
|
||||
|
||||
bool result = cmd->execute(UClientImage_Base::body->empty() ? U_NULLPTR : UClientImage_Base::body, UClientImage_Base::wbuffer, -1, fd_stderr);
|
||||
bool result = cmd->execute(body->empty() ? U_NULLPTR : body, UClientImage_Base::wbuffer, -1, fd_stderr);
|
||||
|
||||
if (cgi) (void) UFile::chdir(U_NULLPTR, true);
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
01E8
|
||||
0213
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_db() { World::handlerForkSql(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
World::initOneResult();
|
||||
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_edb() { WorldNoSql::handlerForkElasticSearch(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
WorldNoSql::doOneQuery(WorldNoSql::handlerQueryElasticSearch);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_equery() { WorldNoSql::handlerForkElasticSearch(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
WorldNoSql::doQuery(WorldNoSql::handlerQueryElasticSearch);
|
||||
-->
|
||||
|
|
|
@ -23,9 +23,6 @@ static void usp_fork_eupdate()
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
World::doUpdateNoSql(WorldNoSql::handlerUpdateElasticSearch);
|
||||
-->
|
||||
|
|
|
@ -72,9 +72,6 @@ static void usp_fork_fortune()
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
Fortune::doQuery(handle_query);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_mdb() { WorldNoSql::handlerForkMongoDB(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
WorldNoSql::doOneQuery(WorldNoSql::handlerQueryMongoDB);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_mfortune() { FortuneNoSql::handlerForkMongoDB(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
Fortune::doQuery(FortuneNoSql::handlerQueryMongoDB);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_mquery() { WorldNoSql::handlerForkMongoDB(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
WorldNoSql::doQuery(WorldNoSql::handlerQueryMongoDB);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_mupdate() { WorldNoSql::handlerForkMongoDB(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
World::doUpdateNoSql(WorldNoSql::handlerUpdateMongoDB);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_query() { World::handlerForkSql(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
uint32_t i = 0, num_queries = UHTTP::getFormFirstNumericValue(1, 500);
|
||||
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_rdb() { WorldNoSql::handlerForkREDIS(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
WorldNoSql::doOneQuery(WorldNoSql::handlerQueryREDIS);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_rfortune() { FortuneNoSql::handlerForkREDIS(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
Fortune::doQuery(FortuneNoSql::handlerQueryREDIS);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_rquery() { WorldNoSql::handlerForkREDIS(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
WorldNoSql::doQuery(WorldNoSql::handlerQueryREDIS);
|
||||
-->
|
||||
|
|
|
@ -9,9 +9,6 @@ static void usp_fork_rupdate() { WorldNoSql::handlerForkREDIS(); }
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
World::doUpdateNoSql(WorldNoSql::handlerUpdateREDIS);
|
||||
-->
|
||||
|
|
|
@ -32,9 +32,6 @@ static void usp_fork_update()
|
|||
-->
|
||||
<!--#header
|
||||
-->
|
||||
<!--#vcode
|
||||
if (UServer_Base::startParallelization()) return;
|
||||
-->
|
||||
<!--#code
|
||||
uint32_t i = 0, num_queries = UHTTP::getFormFirstNumericValue(1, 500);
|
||||
|
||||
|
|
|
@ -6,10 +6,14 @@
|
|||
|
||||
start_msg tsa_http
|
||||
|
||||
#UTRACE="0 75M 0"
|
||||
#UOBJDUMP="0 10M 10"
|
||||
#UTRACE="0 50M -1"
|
||||
#UTRACE_SIGNAL="0 50M -1"
|
||||
UTRACE_FOLDER=/tmp
|
||||
TMPDIR=/tmp
|
||||
#UOBJDUMP="0 10M 100"
|
||||
#USIMERR="error.sim"
|
||||
export UTRACE UOBJDUMP USIMERR
|
||||
#UMEMUSAGE=yes
|
||||
export UTRACE UOBJDUMP USIMERR UTRACE_SIGNAL UMEMUSAGE UTRACE_FOLDER TMPDIR
|
||||
|
||||
DOC_ROOT=TSA
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
|
||||
(cd benchmark; rm -f db; creat_link FrameworkBenchmarks/ULib/db db)
|
||||
|
||||
#DOC_ROOT=docroot
|
||||
DOC_ROOT=sse_example
|
||||
DOC_ROOT=docroot
|
||||
#DOC_ROOT=sse_example
|
||||
#DOC_ROOT=ruby/blog
|
||||
#DOC_ROOT=benchmark/docroot
|
||||
#DOC_ROOT=ShivShankarDayal/docroot
|
||||
|
@ -17,7 +17,7 @@ rm -f tmp/usp_compile.sh.err /tmp/*.hpack.* \
|
|||
$DOC_ROOT/trace.*userver_*.[0-9]* $DOC_ROOT/object.*userver_*.[0-9]* $DOC_ROOT/stack.*userver_*.[0-9]* $DOC_ROOT/mempool.*userver_*.[0-9]*
|
||||
|
||||
#UTRACE="0 50M 0"
|
||||
UTRACE_SIGNAL="0 50M 0"
|
||||
UTRACE_SIGNAL="0 50M -1"
|
||||
UTRACE_FOLDER=/tmp
|
||||
TMPDIR=/tmp
|
||||
#UOBJDUMP="0 10M 100"
|
||||
|
@ -60,7 +60,7 @@ start_test() {
|
|||
|
||||
cat <<EOF >inp/webserver.cfg
|
||||
userver {
|
||||
PORT 8888
|
||||
PORT 8080
|
||||
RUN_AS_USER nobody
|
||||
MIN_SIZE_FOR_SENDFILE 2k
|
||||
LOG_FILE web_server.log
|
||||
|
|
|
@ -25,9 +25,12 @@ rm -f db/session.ssl* /tmp/ssl_session.txt /tmp/byterange* /tmp/soap.res /tmp/*.
|
|||
|
||||
#UTRACE="0 50M 0"
|
||||
UTRACE_SIGNAL="0 50M -1"
|
||||
UTRACE_FOLDER=/tmp
|
||||
TMPDIR=/tmp
|
||||
#UOBJDUMP="0 10M 100"
|
||||
#USIMERR="error.sim"
|
||||
export UTRACE UOBJDUMP USIMERR UTRACE_SIGNAL
|
||||
#UMEMUSAGE=yes
|
||||
export UTRACE UOBJDUMP USIMERR UTRACE_SIGNAL UMEMUSAGE UTRACE_FOLDER TMPDIR
|
||||
|
||||
if [ "$TERM" = "msys" ]; then
|
||||
export TMPDIR="c:/tmp"
|
||||
|
|
Loading…
Reference in New Issue
Block a user