updated dependency version strings, and added test for response output stream.
Build and Test Module / build-and-test (push) Successful in 12s
Details
Build and Test Module / build-and-test (push) Successful in 12s
Details
This commit is contained in:
parent
b06cb7547f
commit
4709f8b00c
6
dub.json
6
dub.json
|
@ -4,9 +4,9 @@
|
||||||
],
|
],
|
||||||
"copyright": "Copyright © 2024, Andrew Lalis",
|
"copyright": "Copyright © 2024, Andrew Lalis",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"handy-http-primitives": "~>1",
|
"handy-http-primitives": "~>1.2",
|
||||||
"photon": "~>0.10.2",
|
"photon": "~>0.10",
|
||||||
"streams": "~>3"
|
"streams": "~>3.5"
|
||||||
},
|
},
|
||||||
"description": "Implementations of HTTP transport protocols.",
|
"description": "Implementations of HTTP transport protocols.",
|
||||||
"license": "CC0",
|
"license": "CC0",
|
||||||
|
|
|
@ -100,3 +100,25 @@ struct HttpResponseOutputStream(S) if (isByteOutputStream!S) {
|
||||||
return StreamResult(cast(uint) writeCount);
|
return StreamResult(cast(uint) writeCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test basic functionality for writing a standard response with headers and a
|
||||||
|
// body.
|
||||||
|
unittest {
|
||||||
|
import handy_http_primitives.response;
|
||||||
|
|
||||||
|
ArrayOutputStream!ubyte os;
|
||||||
|
ServerHttpResponse resp;
|
||||||
|
resp.status = HttpStatus.OK;
|
||||||
|
resp.headers.add("Content-Type", "text/plain");
|
||||||
|
auto httpOut = HttpResponseOutputStream!(ArrayOutputStream!ubyte*)(&os, &resp);
|
||||||
|
resp.outputStream = outputStreamObjectFor(httpOut);
|
||||||
|
StreamResult r = resp.outputStream.writeToStream(cast(ubyte[]) "Hello world!");
|
||||||
|
const expectedOutput =
|
||||||
|
"HTTP/1.1 200 OK\r\n" ~
|
||||||
|
"Content-Type: text/plain\r\n" ~
|
||||||
|
"\r\n" ~
|
||||||
|
"Hello world!";
|
||||||
|
assert(os.toArray() == expectedOutput);
|
||||||
|
assert(r.hasCount);
|
||||||
|
assert(r.count == os.toArray().length);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue