Lolly 1.4.27
Loading...
Searching...
No Matches
Functions
http_test.cpp File Reference
#include "a_lolly_test.hpp"
#include "file.hpp"
#include "hashmap.hpp"
#include "lolly/io/http.hpp"
Include dependency graph for http_test.cpp:

Go to the source code of this file.

Functions

 TEST_CASE ("http::head")
 
 TEST_CASE ("http::get")
 
 TEST_CASE ("http::download")
 

Detailed Description

Unitests for http.

Author
Darcy Shen
Date
2023

Definition in file http_test.cpp.

Function Documentation

◆ TEST_CASE() [1/3]

TEST_CASE ( "http::head" )

Definition at line 15 of file http_test.cpp.

15 {
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}
The list class represents a linked list.
Definition list.hpp:48
void string_eq(string left, string right)
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

◆ TEST_CASE() [2/3]

TEST_CASE ( "http::get" )

Definition at line 27 of file http_test.cpp.

27 {
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}
http_tree http_get(url u, http_headers headers)
Definition http.cpp:92

◆ TEST_CASE() [3/3]

TEST_CASE ( "http::download" )

Definition at line 39 of file http_test.cpp.

39 {
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}
Definition url.hpp:37
url url_temp_dir()
Definition file.cpp:300
int file_size(url u)
Definition file.cpp:155
http_tree download(url from, url to, http_headers headers)
Definition http.cpp:118