Simplify print statements by using HTTP_UNPACK
This commit is contained in:
@@ -43,7 +43,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
printf("Status: %d\n", result->status);
|
||||
printf("Body: %.*s\n", (int)result->body.len, result->body.ptr);
|
||||
printf("Body: %.*s\n", HTTP_UNPACK(result->body));
|
||||
|
||||
http_request_free(reqs[i-1]);
|
||||
}
|
||||
|
||||
@@ -173,11 +173,11 @@ int main(int argc, char **argv)
|
||||
if (url.len == 0) break;
|
||||
|
||||
if (is_already_crawled(url)) {
|
||||
printf("Ignoring " RED "%.*s" RST "\n", (int) url.len, url.ptr);
|
||||
printf("Ignoring " RED "%.*s" RST "\n", HTTP_UNPACK(url));
|
||||
continue;
|
||||
}
|
||||
|
||||
printf("Fetching " GRN "%.*s" RST "\n", (int) url.len, url.ptr);
|
||||
printf("Fetching " GRN "%.*s" RST "\n", HTTP_UNPACK(url));
|
||||
add_to_crawled_list(url);
|
||||
|
||||
HTTP_RequestHandle req;
|
||||
|
||||
@@ -48,7 +48,7 @@ int main(void)
|
||||
// sure to express the length when interacting with
|
||||
// libc:
|
||||
HTTP_String path = req->url.path;
|
||||
printf("requested path [%.*s]\n", (int) path.len, path.ptr);
|
||||
printf("requested path [%.*s]\n", HTTP_UNPACK(path));
|
||||
|
||||
// To find a specific header value, you can either
|
||||
// iterate over the [req->headers] array or use
|
||||
@@ -60,7 +60,7 @@ int main(void)
|
||||
} else {
|
||||
// Found
|
||||
HTTP_String value = req->headers[idx].value;
|
||||
printf("Header has value [%.*s]\n", (int) value.len, value.ptr);
|
||||
printf("Header has value [%.*s]\n", HTTP_UNPACK(value));
|
||||
}
|
||||
|
||||
// To create a response, you will need to specify
|
||||
|
||||
Reference in New Issue
Block a user