mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
StaticConditionVariable fix
git-svn-id: svn://ultimatepp.org/upp/trunk@1006 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
1f9a9ecdbf
commit
731da142dc
5 changed files with 2057 additions and 2095 deletions
|
|
@ -501,6 +501,13 @@ void StaticSemaphore::Initialize()
|
|||
BarrierWrite(semaphore, new(buffer) Semaphore);
|
||||
}
|
||||
|
||||
void StaticConditionVariable::Initialize()
|
||||
{
|
||||
Mutex::Lock __(sMutexLock());
|
||||
if(!ReadWithBarrier(cv))
|
||||
BarrierWrite(cv, new(buffer) ConditionVariable);
|
||||
}
|
||||
|
||||
void LazyUpdate::Invalidate()
|
||||
{
|
||||
dirty = true;
|
||||
|
|
|
|||
|
|
@ -2,11 +2,17 @@
|
|||
|
||||
NAMESPACE_UPP
|
||||
|
||||
#define LLOG(x) RLOG(x)
|
||||
#define LLOGBLOCK(x) // RLOGBLOCK(x)
|
||||
#define LDUMP(x) // RDUMP(x)
|
||||
bool HttpClient_Trace__;
|
||||
|
||||
HttpClient::HttpClient()
|
||||
#define LLOG(x) if(HttpClient_Trace__) RLOG(x); else;
|
||||
#define LLOGBLOCK(x) // DLOGBLOCK(x)
|
||||
|
||||
void HttpClient::Trace(bool b)
|
||||
{
|
||||
HttpClient_Trace__ = b;
|
||||
}
|
||||
|
||||
void HttpClient::Init()
|
||||
{
|
||||
port = DEFAULT_PORT;
|
||||
timeout_msecs = DEFAULT_TIMEOUT_MSECS;
|
||||
|
|
@ -17,6 +23,18 @@ HttpClient::HttpClient()
|
|||
method = METHOD_GET;
|
||||
}
|
||||
|
||||
|
||||
HttpClient::HttpClient()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
HttpClient::HttpClient(const char *url)
|
||||
{
|
||||
Init();
|
||||
URL(url);
|
||||
}
|
||||
|
||||
HttpClient& HttpClient::URL(const char *u)
|
||||
{
|
||||
const char *t = u;
|
||||
|
|
@ -105,6 +123,14 @@ String HttpClient::ReadUntilProgress(char until, int start_time, int end_time, G
|
|||
return String::GetVoid();
|
||||
}
|
||||
|
||||
HttpClient& HttpClient::PostU(const char *key, const String& data)
|
||||
{
|
||||
if(postdata.GetCount())
|
||||
postdata << '&';
|
||||
postdata << key << '=' << UrlEncode(data);
|
||||
return *this;
|
||||
}
|
||||
|
||||
String HttpClient::Execute(Gate2<int, int> progress)
|
||||
{
|
||||
LLOGBLOCK("HttpClient::Execute");
|
||||
|
|
@ -143,9 +169,14 @@ String HttpClient::Execute(Gate2<int, int> progress)
|
|||
}
|
||||
}
|
||||
String request;
|
||||
String ctype = contenttype;
|
||||
switch(method) {
|
||||
case METHOD_GET: request << "GET "; break;
|
||||
case METHOD_POST: request << "POST "; break;
|
||||
case METHOD_POST:
|
||||
request << "POST ";
|
||||
if(IsNull(ctype))
|
||||
ctype = "application/x-www-form-urlencoded";
|
||||
break;
|
||||
case METHOD_HEAD: request << "HEAD "; break;
|
||||
default: NEVER(); // invalid method
|
||||
}
|
||||
|
|
@ -171,6 +202,8 @@ String HttpClient::Execute(Gate2<int, int> progress)
|
|||
request << "Agent: " << Nvl(agent, "Ultimate++ HTTP client") << "\r\n";
|
||||
if(method == METHOD_POST)
|
||||
request << "Content-Length: " << postdata.GetLength() << "\r\n";
|
||||
if(ctype.GetCount())
|
||||
request << "Content-Type: " << ctype << "\r\n";
|
||||
}
|
||||
if(use_proxy && !IsNull(proxy_username))
|
||||
request << "Proxy-Authorization: basic " << Base64Encode(proxy_username + ':' + proxy_password) << "\r\n";
|
||||
|
|
@ -220,6 +253,7 @@ String HttpClient::Execute(Gate2<int, int> progress)
|
|||
bool ce_gzip = false;
|
||||
for(;;) {
|
||||
String line = ReadUntilProgress('\n', start_time, end_time, progress);
|
||||
LLOG("< " << line);
|
||||
if(socket.IsError()) {
|
||||
error = Socket::GetErrorText();
|
||||
return String::GetVoid();
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ class HttpClient
|
|||
{
|
||||
public:
|
||||
HttpClient();
|
||||
HttpClient(const char *url);
|
||||
|
||||
HttpClient& TimeoutMsecs(int t) { timeout_msecs = t; return *this; }
|
||||
HttpClient& MaxHeaderSize(int m) { max_header_size = m; return *this; }
|
||||
|
|
@ -28,6 +29,7 @@ public:
|
|||
HttpClient& NoStdHeaders() { return StdHeaders(false); }
|
||||
HttpClient& Accept(String a) { accept = a; return *this; }
|
||||
HttpClient& Agent(String a) { agent = a; return *this; }
|
||||
HttpClient& ContentType(String a) { contenttype = a; return *this; }
|
||||
|
||||
HttpClient& Method(int m) { method = m; return *this; }
|
||||
HttpClient& Get() { return Method(METHOD_GET); }
|
||||
|
|
@ -35,6 +37,10 @@ public:
|
|||
HttpClient& Head() { return Method(METHOD_HEAD); }
|
||||
|
||||
HttpClient& PostData(String pd) { postdata = pd; return *this; }
|
||||
HttpClient& PostUData(String pd) { return PostData(UrlEncode(pd)); }
|
||||
HttpClient& Post(const String& data) { Post(); return PostData(data); }
|
||||
HttpClient& PostU(const String& data) { Post(); return PostUData(data); }
|
||||
HttpClient& PostU(const char *key, const String& data);
|
||||
|
||||
String Execute(Gate2<int, int> progress = false);
|
||||
String ExecuteRedirect(int max_redirect = DEFAULT_MAX_REDIRECT,
|
||||
|
|
@ -53,6 +59,8 @@ public:
|
|||
|
||||
void Close() { socket.Close(); }
|
||||
|
||||
static void Trace(bool b = true);
|
||||
|
||||
public:
|
||||
Socket socket;
|
||||
bool keepalive;
|
||||
|
|
@ -78,6 +86,7 @@ public:
|
|||
String client_headers;
|
||||
String accept;
|
||||
String agent;
|
||||
String contenttype;
|
||||
String postdata;
|
||||
|
||||
int status_code;
|
||||
|
|
@ -103,6 +112,7 @@ public:
|
|||
};
|
||||
|
||||
private:
|
||||
void Init();
|
||||
String ReadUntilProgress(char until, int start_time, int end_time, Gate2<int, int> progress);
|
||||
};
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
4091
uppsrc/ide/ide.iml
4091
uppsrc/ide/ide.iml
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue