HTTPClient fork Support for Plantus Headers authentification

Fork of HTTPClient by Donatien Garnier

Files at this revision

API Documentation at this revision

Comitter:
Jonathan Santerre
Date:
Mon Mar 27 16:19:24 2017 -0400
Parent:
18:277279a1891e
Commit message:
Adapt lib to work with plantus api

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
data/HTTPText.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/HTTPClient.cpp	Wed May 07 16:48:10 2014 +0000
+++ b/HTTPClient.cpp	Mon Mar 27 16:19:24 2017 -0400
@@ -46,8 +46,8 @@
 
 #include "HTTPClient.h"
 
-HTTPClient::HTTPClient() :
-m_sock(), m_basicAuthUser(NULL), m_basicAuthPassword(NULL), m_httpResponseCode(0)
+HTTPClient::HTTPClient(const char* identifier) :
+m_sock(), m_basicAuthUser(NULL), m_basicAuthPassword(NULL), m_httpResponseCode(0), identifier(identifier)
 {
 
 }
@@ -173,6 +173,12 @@
 
   //Send default headers
   DBG("Sending headers");
+  
+  DBG("X-Authorization: %s\r\n", identifier);
+  snprintf(buf, sizeof(buf), "X-Authorization: %s\r\n", identifier);
+  ret = send(buf);
+  CHECK_CONN_ERR(ret);
+
   if( pDataOut != NULL )
   {
     if( pDataOut->getIsChunked() )
--- a/HTTPClient.h	Wed May 07 16:48:10 2014 +0000
+++ b/HTTPClient.h	Mon Mar 27 16:19:24 2017 -0400
@@ -58,7 +58,7 @@
 {
 public:
   ///Instantiate the HTTP client
-  HTTPClient();
+  HTTPClient(const char*);
   ~HTTPClient();
   
 #if 0 //TODO add header handlers
@@ -149,6 +149,7 @@
   const char* m_basicAuthUser;
   const char* m_basicAuthPassword;
   int m_httpResponseCode;
+  const char* identifier;
 
 };
 
--- a/data/HTTPText.cpp	Wed May 07 16:48:10 2014 +0000
+++ b/data/HTTPText.cpp	Mon Mar 27 16:19:24 2017 -0400
@@ -55,7 +55,7 @@
 
 /*virtual*/ int HTTPText::getDataType(char* type, size_t maxTypeLen) //Internet media type for Content-Type header
 {
-  strncpy(type, "text/plain", maxTypeLen-1);
+  strncpy(type, "application/json", maxTypeLen-1);
   type[maxTypeLen-1] = '\0';
   return OK;
 }