fork of HTTPClient, adding custom content type for HTTPText (for now)

Fork of HTTPClient by wolf SSL

Files at this revision

API Documentation at this revision

Comitter:
mitsarionas
Date:
Mon Sep 28 08:54:27 2015 +0000
Parent:
33:77082c88748a
Commit message:
settable content type for HTTPText

Changed in this revision

data/HTTPText.cpp Show annotated file Show diff for this revision Revisions of this file
data/HTTPText.h Show annotated file Show diff for this revision Revisions of this file
diff -r 77082c88748a -r 09abfb894400 data/HTTPText.cpp
--- a/data/HTTPText.cpp	Tue Jul 21 01:07:25 2015 +0000
+++ b/data/HTTPText.cpp	Mon Sep 28 08:54:27 2015 +0000
@@ -36,7 +36,7 @@
 
 HTTPText::HTTPText(char* str, size_t size) : m_str(str), m_size(size), m_pos(0)
 {
-
+    m_datatype = "text/plain";
 }
 
 //IHTTPDataIn
@@ -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, m_datatype.c_str(), maxTypeLen-1);
   type[maxTypeLen-1] = '\0';
   return OK;
 }
@@ -85,9 +85,9 @@
   return OK;
 }
 
-/*virtual*/ void HTTPText::setDataType(const char* type) //Internet media type from Content-Type header
+void HTTPText::setDataType(const char* type) //Internet media type from Content-Type header
 {
-
+    m_datatype = type;
 }
 
 /*virtual*/ void HTTPText::setIsChunked(bool chunked) //From Transfer-Encoding header
@@ -99,6 +99,3 @@
 {
 
 }
-
-
-
diff -r 77082c88748a -r 09abfb894400 data/HTTPText.h
--- a/data/HTTPText.h	Tue Jul 21 01:07:25 2015 +0000
+++ b/data/HTTPText.h	Mon Sep 28 08:54:27 2015 +0000
@@ -21,6 +21,7 @@
 #ifndef HTTPTEXT_H_
 #define HTTPTEXT_H_
 
+#include <string>
 #include "../IHTTPData.h"
 
 /** A data endpoint to store text
@@ -38,6 +39,8 @@
    * @param size Size of the buffer
    */
   HTTPText(char* str, size_t size);
+  
+  virtual void setDataType(const char* type); //Internet media type from Content-Type header
 
 protected:
   //IHTTPDataIn
@@ -56,8 +59,6 @@
   
   virtual int write(const char* buf, size_t len);
 
-  virtual void setDataType(const char* type); //Internet media type from Content-Type header
-
   virtual void setIsChunked(bool chunked); //From Transfer-Encoding header
 
   virtual void setDataLen(size_t len); //From Content-Length header, or if the transfer is chunked, next chunk length
@@ -67,6 +68,7 @@
   size_t m_size;
 
   size_t m_pos;
+  std::string m_datatype;
 };
 
 #endif /* HTTPTEXT_H_ */