David Smart / HTTPClient Featured

Dependents:   Sample_HTTPClient Sample_HTTPClient LWM2M_NanoService_Ethernet LWM2M_NanoService_Ethernet ... more

Fork of HTTPClient by Vincent Wochnik

More recent changes - added iCal processing.

Derivative of a derivative, however this one works when it comes to supplying Basic authorization to access a protected resource. Some additional changes to the debug interface to clean it up for consistency with many other components I have.

Files at this revision

API Documentation at this revision

Comitter:
WiredHome
Date:
Thu Dec 29 20:14:53 2016 +0000
Parent:
37:74c1c4527f70
Child:
39:21fc7a4b6927
Commit message:
Added a method to translate a return code to a text message

Changed in this revision

HTTPClient.cpp Show annotated file Show diff for this revision Revisions of this file
HTTPClient.h Show annotated file Show diff for this revision Revisions of this file
--- a/HTTPClient.cpp	Sat Dec 17 15:19:55 2016 +0000
+++ b/HTTPClient.cpp	Thu Dec 29 20:14:53 2016 +0000
@@ -67,6 +67,29 @@
     m_location = NULL;      // this step isn't necessary...
 }
 
+
+const char * HTTPClient::GetErrorMessage(HTTPResult res)
+{
+    const char * msg[HTTP_CLOSED+1] = {
+        "HTTP OK",            ///<Success
+        "HTTP Processing",    ///<Processing
+        "HTTP URL Parse error",         ///<url Parse error
+        "HTTP DNS error",           ///<Could not resolve name
+        "HTTP Protocol error",         ///<Protocol error
+        "HTTP 404 Not Found",      ///<HTTP 404 Error
+        "HTTP 403 Refused",       ///<HTTP 403 Error
+        "HTTP ### Error",         ///<HTTP xxx error
+        "HTTP Timeout",       ///<Connection timeout
+        "HTTP Connection error",          ///<Connection error
+        "HTTP Closed by remote host"         ///<Connection was closed by remote host
+    };
+    if (res <= HTTP_CLOSED)
+        return msg[res];
+    else
+        return "HTTP Unknown Code";
+};
+
+
 void HTTPClient::basicAuth(const char* user, const char* password) //Basic Authentification
 {
 #if 1
--- a/HTTPClient.h	Sat Dec 17 15:19:55 2016 +0000
+++ b/HTTPClient.h	Thu Dec 29 20:14:53 2016 +0000
@@ -60,6 +60,15 @@
     HTTPClient();
     ~HTTPClient();
 
+    /// Get the text form of the error number
+    /// 
+    /// Gets a pointer to a text message that described the result code.
+    ///
+    /// @param[in] res is the HTTPResult code to translate to text.
+    /// @returns a pointer to a text message.
+    ///
+    static const char * GetErrorMessage(HTTPResult res);
+
     /**
     Provides a basic authentification feature (Base64 encoded username and password)
     Pass two NULL pointers to switch back to no authentication