The OpenD Programming Language

HTTPRequest.exec

POST/PUT/... data from some string(with Content-Length), or from range of strings/bytes (use Transfer-Encoding: chunked). When rank 1 (flat array) used as content it must have length. In that case "content" will be sent directly to network, and Content-Length headers will be added. If you are goung to send some range and do not know length at the moment when you start to send request, then you can send chunks of chars or ubyte. Try not to send too short chunks as this will put additional load on client and server. Chunks of length 2048 or 4096 are ok.

  1. HTTPResponse exec(string url, MultipartForm sources)
  2. HTTPResponse exec(string url, R content, string contentType)
    struct HTTPRequest
    deprecated
    exec
    (
    string method = "POST"
    R
    )
    (
    string url
    ,,
    string contentType = "application/octet-stream"
    )
    if (
    (rank!R == 1) ||
    (
    rank!R == 2 &&
    isSomeChar!(Unqual!(typeof(content.front.front)))
    )
    ||
    (
    rank!R == 2 &&
    (is(Unqual!(typeof(content.front.front)) == ubyte))
    )
    )
  3. HTTPResponse exec(string url, QueryParam[] params)
  4. HTTPResponse exec(string url, PostFile[] files)
  5. HTTPResponse exec(string url, string[string] params)

Parameters

url string

url

content R

string or input range

contentType string

content type

Return Value

Response

Examples

rs = rq.exec!"POST"("http://httpbin.org/post", "привiт, свiт!", "application/octet-stream");

auto s = lineSplitter("one,\ntwo,\nthree.");
rs = rq.exec!"POST"("http://httpbin.org/post", s, "application/octet-stream");

auto s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
rs = rq.exec!"POST"("http://httpbin.org/post", s.representation.chunks(10), "application/octet-stream");

auto f = File("tests/test.txt", "rb");
rs = rq.exec!"POST"("http://httpbin.org/post", f.byChunk(3), "application/octet-stream");

Meta