Created
February 15, 2015 18:13
-
-
Save yannick/8ab93ad5b84e7561404a to your computer and use it in GitHub Desktop.
vibed.d requestHTTP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct ApiResponse{ int code; string bdy;}; | |
static string UA = "xxx"; | |
ApiResponse get_article(string url_part1, string url_part2) { | |
ApiResponse ret; | |
auto url = "http://" ~ url_part1 ~ "/blabla/" ~ url_part2; | |
requestHTTP(url, | |
(scope r) { | |
r.method = HTTPMethod.GET; | |
r.headers["User-Agent"] = UA; | |
}, | |
(scope res) { | |
ret = ApiResponse(res.statusCode, res.bodyReader.readAllUTF8() ); | |
} | |
); | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment