Skip to content

Commit

Permalink
std.curl: document public methods
Browse files Browse the repository at this point in the history
  • Loading branch information
wilzbach committed May 27, 2016
1 parent 80594b0 commit b89adfc
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions std/net/curl.d
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,6 @@ version(unittest)
}
version(StdDdoc) import std.stdio;

extern (C) void exit(int);

// Default data timeout for Protocols
private enum _defaultDataTimeout = dur!"minutes"(2);

Expand Down Expand Up @@ -1510,12 +1508,10 @@ private mixin template WorkerThreadProtocol(Unit, alias units)
}
}

// Workaround bug #2458
// It should really be defined inside the byLineAsync method.
// Do not create instances of this struct since it will be
// moved when the bug has been fixed.
// @@@@BUG 15831@@@@
// this should be inside byLineAsync
// Range that reads one line at a time asynchronously.
static struct AsyncLineInputRange(Char)
private static struct AsyncLineInputRange(Char)
{
private Char[] line;
mixin WorkerThreadProtocol!(Char, line);
Expand All @@ -1539,7 +1535,6 @@ static struct AsyncLineInputRange(Char)
}
}


/** HTTP/FTP fetch content as a range of lines asynchronously.
*
* A range of lines is returned immediately and the request that fetches the
Expand Down Expand Up @@ -1664,13 +1659,10 @@ unittest
}
}


// Workaround bug #2458
// It should really be defined inside the byLineAsync method.
// Do not create instances of this struct since it will be
// moved when the bug has been fixed.
// @@@@BUG 15831@@@@
// this should be inside byLineAsync
// Range that reads one chunk at a time asynchronously.
static struct AsyncChunkInputRange
private static struct AsyncChunkInputRange
{
private ubyte[] chunk;
mixin WorkerThreadProtocol!(ubyte, chunk);
Expand Down Expand Up @@ -2445,13 +2437,15 @@ struct HTTP
return http;
}

///
static HTTP opCall()
{
HTTP http;
http.initialize();
return http;
}

///
HTTP dup()
{
HTTP copy;
Expand Down Expand Up @@ -3183,13 +3177,15 @@ struct FTP
return ftp;
}

///
static FTP opCall()
{
FTP ftp;
ftp.initialize();
return ftp;
}

///
FTP dup()
{
FTP copy = FTP();
Expand Down Expand Up @@ -3524,6 +3520,7 @@ struct SMTP
return smtp;
}

///
static SMTP opCall()
{
SMTP smtp;
Expand Down Expand Up @@ -3973,7 +3970,7 @@ struct Curl
{
alias OutData = void[];
alias InData = ubyte[];
bool stopped;
private bool _stopped;

private static auto ref curl() @property { return CurlAPI.instance; }

Expand All @@ -4000,10 +3997,16 @@ struct Curl
enforce!CurlException(!handle, "Curl instance already initialized");
handle = curl.easy_init();
enforce!CurlException(handle, "Curl instance couldn't be initialized");
stopped = false;
_stopped = false;
set(CurlOption.nosignal, 1);
}

///
@property bool stopped() const
{
return _stopped;
}

/**
Duplicate this handle.
Expand All @@ -4016,7 +4019,7 @@ struct Curl
{
Curl copy;
copy.handle = curl.easy_duphandle(handle);
copy.stopped = false;
copy._stopped = false;

with (CurlOption) {
auto tt = AliasSeq!(file, writefunction, writeheader,
Expand Down Expand Up @@ -4094,7 +4097,7 @@ struct Curl
void shutdown()
{
throwOnStopped();
stopped = true;
_stopped = true;
curl.easy_cleanup(this.handle);
this.handle = null;
}
Expand Down

0 comments on commit b89adfc

Please sign in to comment.