Skip to content

Commit

Permalink
Merge pull request #4314 from wilzbach/public_document_curl
Browse files Browse the repository at this point in the history
std.curl: document public methods
  • Loading branch information
DmitryOlshansky committed Jun 3, 2016
2 parents 97a8e79 + b89adfc commit 8d424b1
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 @@ -1511,12 +1509,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 @@ -1540,7 +1536,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 @@ -1665,13 +1660,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 @@ -2446,13 +2438,15 @@ struct HTTP
return http;
}

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

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

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

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

///
static SMTP opCall()
{
SMTP smtp;
Expand Down Expand Up @@ -3974,7 +3971,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 @@ -4001,10 +3998,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 @@ -4017,7 +4020,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 @@ -4095,7 +4098,7 @@ struct Curl
void shutdown()
{
throwOnStopped();
stopped = true;
_stopped = true;
curl.easy_cleanup(this.handle);
this.handle = null;
}
Expand Down

0 comments on commit 8d424b1

Please sign in to comment.