Lolly 1.4.28
Loading...
Searching...
No Matches
http_test.cpp
Go to the documentation of this file.
1/** \file http_test.cpp
2 * \copyright GPLv3
3 * \details Unitests for http.
4 * \author Darcy Shen
5 * \date 2023
6 */
7
8#include "a_lolly_test.hpp"
9#include "file.hpp"
10#include "hashmap.hpp"
11#include "lolly/io/http.hpp"
12
13using namespace lolly::io;
14
15TEST_CASE ("http::head") {
16#ifndef OS_WASM
17 http_tree r = http_head ("https://httpbin.org/get");
19 CHECK_EQ (status_code, 200);
20 auto hmap=
22 string content_type= hmap ("content-type");
23 string_eq (content_type, "application/json");
24#endif
25}
26
27TEST_CASE ("http::get") {
28#ifndef OS_WASM
29 http_tree r = http_get ("https://httpbin.org/get");
31 CHECK_EQ (status_code, 200);
32 auto hmap=
34 string content_type= hmap ("content-type");
35 string_eq (content_type, "application/json");
36#endif
37}
38
39TEST_CASE ("http::download") {
40#ifndef OS_WASM
41 url from= url ("http://mirrors.ustc.edu.cn/gnu/GNUinfo/README");
42 url to = url_temp_dir () * url ("README");
44 CHECK (file_size (to) > 0);
45#endif
46}
The list class represents a linked list.
Definition list.hpp:48
Definition url.hpp:37
url url_temp_dir()
Definition file.cpp:300
int file_size(url u)
Definition file.cpp:155
void string_eq(string left, string right)
http_tree download(url from, url to, http_headers headers)
Definition http.cpp:118
http_tree http_response_ref(http_tree r, http_label op)
Definition http.hpp:55
@ HEADER
Definition http.hpp:29
@ STATUS_CODE
Definition http.hpp:25
http_tree http_head(url u, http_headers headers)
Definition http.cpp:105
http_tree http_get(url u, http_headers headers)
Definition http.cpp:92
TEST_CASE("test for operator+= and advance()")