From e0dbbb82528d08a0240699e4663b539974470f76 Mon Sep 17 00:00:00 2001 From: cxl Date: Sat, 22 Sep 2012 08:33:30 +0000 Subject: [PATCH] examples: httpcli changed to TcpSocket git-svn-id: svn://ultimatepp.org/upp/trunk@5386 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- examples/httpcli/httpcli.upp | 3 ++- examples/httpcli/init | 4 ++++ examples/httpcli/main.cpp | 14 ++++++-------- 3 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 examples/httpcli/init diff --git a/examples/httpcli/httpcli.upp b/examples/httpcli/httpcli.upp index 46a0d0ea5..d4937ad8b 100644 --- a/examples/httpcli/httpcli.upp +++ b/examples/httpcli/httpcli.upp @@ -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 "" = ""; + diff --git a/examples/httpcli/init b/examples/httpcli/init new file mode 100644 index 000000000..94eeb476c --- /dev/null +++ b/examples/httpcli/init @@ -0,0 +1,4 @@ +#ifndef _httpcli_icpp_init_stub +#define _httpcli_icpp_init_stub +#include "Web/init" +#endif diff --git a/examples/httpcli/main.cpp b/examples/httpcli/main.cpp index a1828634c..58de627d5 100644 --- a/examples/httpcli/main.cpp +++ b/examples/httpcli/main.cpp @@ -1,4 +1,4 @@ -#include +#include 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); }