]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
Improve logging of URL fetching and wininet errors
authorJon Turney <jon.turney@dronecode.org.uk>
Wed, 10 May 2017 11:46:58 +0000 (12:46 +0100)
committerJon Turney <jon.turney@dronecode.org.uk>
Thu, 18 May 2017 11:52:31 +0000 (12:52 +0100)
geturl.cc
nio-ie5.cc

index 53c0a3b99ad12c87a22e12e0e540b2717a7901b7..1c1d1c68a5f58b223041fdb6dd7804bd38c2656a 100644 (file)
--- a/geturl.cc
+++ b/geturl.cc
@@ -108,14 +108,12 @@ progress (int bytes)
 static void
 getUrlToStream (const string &_url, io_stream *output)
 {
-  Log (LOG_BABBLE) << "getUrlToStream " << _url << endLog;
   is_local_install = (source == IDC_SOURCE_LOCALDIR);
   init_dialog (_url, 0);
   NetIO *n = NetIO::open (_url.c_str(), true);
   if (!n || !n->ok ())
     {
       delete n;
-      Log (LOG_BABBLE) <<  "getUrlToStream failed!" << endLog;
       throw new Exception (TOSTRING(__LINE__) " " __FILE__, "Error opening url",  APPERR_IO_ERROR);
     }
 
@@ -144,6 +142,8 @@ getUrlToStream (const string &_url, io_stream *output)
   if (n)
     delete (n);
   /* reseeking is up to the recipient if desired */
+
+  Log (LOG_BABBLE) << "Fetched URL: " << _url << endLog;
 }
 
 io_stream *
@@ -152,7 +152,6 @@ get_url_to_membuf (const string &_url, HWND owner)
   io_stream_memory *membuf = new io_stream_memory ();
   try 
     {
-      Log (LOG_BABBLE) << "get_url_to_membuf " << _url << endLog;
       getUrlToStream (_url, membuf);
       
       if (membuf->seek (0, IO_SEEK_SET))
@@ -168,7 +167,6 @@ get_url_to_membuf (const string &_url, HWND owner)
     {
       if (e->errNo() != APPERR_IO_ERROR)
        throw e;
-      Log (LOG_BABBLE) << "get_url_to_membuf failed!" << endLog;
       delete membuf;
       return 0;
     }
@@ -217,7 +215,6 @@ get_url_to_file (const string &_url,
   if (!n || !n->ok ())
     {
       delete n;
-      Log (LOG_BABBLE) <<  "get_url_to_file failed!" << endLog;
       return 1;
     }
 
index daf29ad5e2486d159c63124b954193873a838da0..78ddfdfb3cc6522c8eff482c4dceef12fa066af9 100644 (file)
@@ -26,6 +26,7 @@
 #include "msg.h"
 #include "netio.h"
 #include "nio-ie5.h"
+#include "LogSingleton.h"
 
 static HINTERNET internet_direct = 0;
 static HINTERNET internet_preconfig = 0;
@@ -83,13 +84,18 @@ try_again:
 
   if (!connection)
     {
-      if (GetLastError () == ERROR_INTERNET_EXTENDED_ERROR)
+      DWORD e = GetLastError ();
+      if (e == ERROR_INTERNET_EXTENDED_ERROR)
        {
          char buf[2000];
          DWORD e, l = sizeof (buf);
          InternetGetLastResponseInfo (&e, buf, &l);
          mbox (0, buf, "Internet Error", MB_OK);
        }
+      else
+        {
+          Log (LOG_PLAIN) << "connection error: " << e << endLog;
+        }
     }
 
   DWORD type, type_s;
@@ -106,6 +112,9 @@ try_again:
                         HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER,
                         &type, &type_s, NULL))
        {
+         if (type != 200)
+           Log (LOG_PLAIN) << "HTTP status " << type << " fetching " << url << endLog;
+
          if (type == 401)      /* authorization required */
            {
              flush_io ();
This page took 0.05024 seconds and 5 git commands to generate.