mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:37:35 +00:00
Start working on a Downloader app and backing classes in LibGUI.
LibGUI is slowly becoming LibKitchensink but I'm okay with this for now.
This commit is contained in:
parent
c7365a00f8
commit
8f30657390
21 changed files with 375 additions and 1 deletions
30
Applications/Downloader/main.cpp
Normal file
30
Applications/Downloader/main.cpp
Normal file
|
@ -0,0 +1,30 @@
|
|||
#include <LibGUI/GApplication.h>
|
||||
#include <LibGUI/GHttpRequest.h>
|
||||
#include <LibGUI/GHttpResponse.h>
|
||||
#include <LibGUI/GNetworkJob.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GApplication app(argc, argv);
|
||||
|
||||
GHttpRequest request;
|
||||
request.set_hostname("www.google.com");
|
||||
request.set_path("/");
|
||||
|
||||
auto job = request.schedule();
|
||||
job->on_finish = [&job] (bool success) {
|
||||
if (!success) {
|
||||
dbgprintf("on_finish: request failed :(\n");
|
||||
return;
|
||||
}
|
||||
auto& response = static_cast<const GHttpResponse&>(*job->response());
|
||||
printf("on_receive: code=%d\n", response.code());
|
||||
printf("payload:\n");
|
||||
printf("%s", response.payload().pointer());
|
||||
printf("payload was %d bytes\n", response.payload().size());
|
||||
};
|
||||
|
||||
printf("Entering main loop...\n");
|
||||
return app.exec();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue