examples: httpcli changed to TcpSocket

git-svn-id: svn://ultimatepp.org/upp/trunk@5386 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2012-09-22 08:33:30 +00:00
parent cb7099df0c
commit e0dbbb8252
3 changed files with 12 additions and 9 deletions

View file

@ -1,4 +1,4 @@
description "Command-line driven HTTP client";
description "Command-line driven HTTP client\377";
uses
Web;
@ -8,3 +8,4 @@ file
mainconfig
"" = "";

4
examples/httpcli/init Normal file
View file

@ -0,0 +1,4 @@
#ifndef _httpcli_icpp_init_stub
#define _httpcli_icpp_init_stub
#include "Web/init"
#endif

View file

@ -1,4 +1,4 @@
#include <Web/Web.h>
#include <Core/Core.h>
using namespace Upp;
@ -33,13 +33,11 @@ CONSOLE_APP_MAIN
String url = cmdline[i];
puts(url);
fflush(stdout);
HttpClient client;
client.URL(url);
client.Proxy(proxy);
String content = client.ExecuteRedirect();
puts("[error] " + Nvl(client.GetError(), "OK (no error)"));
puts(NFormat("[status %d] %s\n", client.GetStatusCode(), client.GetStatusLine()));
puts(NFormat("[headers] (%d bytes)\n%s", client.GetHeaders().GetLength(), DumpSpecial(client.GetHeaders())));
HttpRequest request(url);
request.Proxy(proxy);
String content = request.Execute();
puts("[error] " + Nvl(request.GetErrorDesc(), "OK (no error)"));
puts(NFormat("[status %d] %s\n", request.GetStatusCode(), request.GetReasonPhrase()));
puts(NFormat("[content] (%d bytes)\n%s", content.GetLength(), DumpSpecial(content)));
fflush(stdout);
}