Core: HttpRequest now supports alternate method name

git-svn-id: svn://ultimatepp.org/upp/trunk@5977 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2013-04-11 12:36:42 +00:00
parent 1aad3e7bd8
commit 024a16aedc
4 changed files with 18 additions and 7 deletions

View file

@ -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)

View file

@ -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); }

View file

@ -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]()&]

View file

@ -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;