Request.cookie

Set Cookie for http requests. v - array of cookie.

You can set and read cookies. In the next example server set cookie and we read it.

  1. Cookie[] cookie [@property setter]
    struct Request
    @property pure @nogc nothrow
    void
    cookie
    ()
  2. Cookie[] cookie [@property getter]

Examples

void main() {
   rs = rq.get("http://httpbin.org/cookies/set?A=abcd&b=cdef");
   assert(rs.code == 200);
   auto json = parseJSON(cast(string)rs.responseBody.data).object["cookies"].object;
   assert(json["A"].str == "abcd");
   assert(json["b"].str == "cdef");
   foreach(c; rq.cookie) {
       final switch(c.attr) {
           case "A":
                assert(c.value == "abcd");
                break;
           case "b":
                assert(c.value == "cdef");
                break;
        }
    }
}

Meta