From 024a16aedc7b750043519d1cbd319cbf9e4e2199 Mon Sep 17 00:00:00 2001 From: cxl Date: Thu, 11 Apr 2013 12:36:42 +0000 Subject: [PATCH] Core: HttpRequest now supports alternate method name git-svn-id: svn://ultimatepp.org/upp/trunk@5977 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Http.cpp | 9 ++++++++- uppsrc/Core/Inet.h | 3 ++- uppsrc/Core/src.tpp/HttpRequest$en-us.tpp | 11 +++++++---- uppsrc/CtrlCore/Ctrl.cpp | 2 +- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/uppsrc/Core/Http.cpp b/uppsrc/Core/Http.cpp index c3b3401ad..38008bb7e 100644 --- a/uppsrc/Core/Http.cpp +++ b/uppsrc/Core/Http.cpp @@ -52,6 +52,13 @@ HttpRequest::HttpRequest(const char *url) Url(url); } +HttpRequest& HttpRequest::Method(int m, const char *custom_name) +{ + method = m; + custom_method = custom_name; + return *this; +} + HttpRequest& HttpRequest::Url(const char *u) { ssl = memcmp(u, "https", 5) == 0; @@ -458,7 +465,7 @@ void HttpRequest::StartRequest() "GET", "POST", "HEAD", "PUT", "DELETE", "TRACE", "OPTIONS", "CONNECT", "PATCH", }; ASSERT(method >= 0 && method <= 8); - data = smethod[method]; + data = Nvl(custom_method, smethod[method]); data << ' '; String host_port = host; if(port) diff --git a/uppsrc/Core/Inet.h b/uppsrc/Core/Inet.h index 36a08590a..2d9677ec1 100644 --- a/uppsrc/Core/Inet.h +++ b/uppsrc/Core/Inet.h @@ -332,6 +332,7 @@ class HttpRequest : public TcpSocket { bool ssl; int method; + String custom_method; String accept; String agent; bool force_digest; @@ -408,7 +409,7 @@ public: HttpRequest& RequestTimeout(int ms) { timeout = ms; return *this; } HttpRequest& ChunkSize(int n) { chunk = n; return *this; } - HttpRequest& Method(int m) { method = m; return *this; } + HttpRequest& Method(int m, const char *custom_name = NULL); HttpRequest& GET() { return Method(METHOD_GET); } HttpRequest& POST() { return Method(METHOD_POST); } HttpRequest& HEAD() { return Method(METHOD_HEAD); } diff --git a/uppsrc/Core/src.tpp/HttpRequest$en-us.tpp b/uppsrc/Core/src.tpp/HttpRequest$en-us.tpp index 3e11bb710..15534d659 100644 --- a/uppsrc/Core/src.tpp/HttpRequest$en-us.tpp +++ b/uppsrc/Core/src.tpp/HttpRequest$en-us.tpp @@ -74,13 +74,16 @@ ize]([@(0.0.255) int]_[*@3 n])&] [s2;%% Specifies the maximum size of content data block for processing (default is 4096). Returns `*this.&] [s3;%% &] -[s4;%% &] -[s5;:HttpRequest`:`:Method`(int`): [_^HttpRequest^ HttpRequest][@(0.0.255) `&]_[* Method]([@(0.0.255) i -nt]_[*@3 m])&] +[s4; &] +[s5;:HttpRequest`:`:Method`(int`,const char`*`): [_^HttpRequest^ HttpRequest][@(0.0.255) `& +]_[* Method]([@(0.0.255) int]_[*@3 m], [@(0.0.255) const]_[@(0.0.255) char]_`*[*@3 custom`_na +me]_`=_NULL)&] [s2;%% Sets HTTP request method. [%-*@3 m] can be one of METHOD`_GET, METHOD`_POST, METHOD`_HEAD, METHOD`_PUT, METHOD`_DELETE, METHOD`_TRACE, METHOD`_OPTIONS, METHOD`_CONNECT, METHOD`_PATCH. Default setting -is METHOD`_GET. Returns `*this.&] +is METHOD`_GET. If [%-*@3 custom`_name] is not NULL, HttpRequest +behaves likem performing method [%-*@3 m] but in HTTP request [%-*@3 custom`_name] +is used as method. Returns `*this.&] [s3;%% &] [s4;%% &] [s5;:HttpRequest`:`:GET`(`): [_^HttpRequest^ HttpRequest][@(0.0.255) `&]_[* GET]()&] diff --git a/uppsrc/CtrlCore/Ctrl.cpp b/uppsrc/CtrlCore/Ctrl.cpp index 0dc8a1ce1..dd7455b6a 100644 --- a/uppsrc/CtrlCore/Ctrl.cpp +++ b/uppsrc/CtrlCore/Ctrl.cpp @@ -583,7 +583,7 @@ Ctrl::Ctrl() { caretcx = caretcy = caretx = carety = 0; pos.x = PosLeft(0, 0); pos.y = PosTop(0, 0); -// SetRect(Rect(0, 0, 0, 0)); + rect = Rect(0, 0, 0, 0); inloop = popup = isopen = false; modify = false; unicode = false;