Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
HTTPContent.h
00001 #ifndef SmartLab_MuRata_Type_HTTPContent 00002 #define SmartLab_MuRata_Type_HTTPContent 00003 00004 #include <string> 00005 #include <map> 00006 00007 #include "HTTPMethod.h" 00008 00009 using namespace std; 00010 00011 namespace SmartLabMuRata 00012 { 00013 class HTTPContent 00014 { 00015 private: 00016 const static char HEADER_SEPARATE[]; 00017 const static char HEADER_TEMINATE[]; 00018 00019 int remotePort; 00020 int contentLength; 00021 HTTPMethod method; 00022 char timeout; 00023 00024 string remoteHost; 00025 string uri; 00026 string contentType; 00027 00028 map<const char *, const char *> otherHeaders; 00029 00030 char * body; 00031 00032 /// <summary> 00033 /// URI, Content Type, and Other header are all NUL terminated char strings. URI must be specified, e.g., “index.htm”. If Content Type is an empty string, the default will be “text/plain”. If it is a GET, 00034 /// </summary> 00035 /// <param name="method"></param> 00036 /// <param name="remoteHost"></param> 00037 /// <param name="remotePort"></param> 00038 /// <param name="uri"></param> 00039 /// <param name="timeout"></param> 00040 /// <param name="contentType"></param> 00041 public : 00042 00043 HTTPContent(const HTTPMethod method, const char * remoteHost,const int remotePort,const char * uri,const char timeout, const char * contentType = NULL); 00044 00045 ~HTTPContent(); 00046 00047 HTTPMethod GetMethod(); 00048 00049 HTTPContent * SetMethod(const HTTPMethod method); 00050 00051 char GetTimeout(); 00052 00053 /// <summary> 00054 /// Timeout is in seconds. If Timeout is 0, it means wait forever. A complete HTTP request will block other commands until either a response is received or timeout. So timeout value of 0 is not recommended. If timeout happens, the response status code would be SNIC_TIMEOUT. If it is chunked encoding in the response, the last chunk should be received before Timeout; otherwise, the connection is closed. If the HTTP request has more data to send (POST), it is not considered a complete HTTP request, and other commands are not blocked until the series of SNIC_HTTP_MORE_REQ are finished. 00055 /// </summary> 00056 /// <param name="timeout"></param> 00057 /// <returns></returns> 00058 HTTPContent * SetTimeout(const char timeout); 00059 00060 int GetRemotePort(); 00061 00062 HTTPContent * SetRemotePort(const int port); 00063 00064 const char * GetRemoteHost() ; 00065 00066 HTTPContent * SetRemoteHost(const char * host); 00067 00068 const char * GetURI(); 00069 00070 HTTPContent * SetURI(const char * uri) ; 00071 00072 const char * GetContentType(); 00073 00074 HTTPContent * SetContentType(const char * contentType); 00075 00076 //const string * GetOtherHeader(const string * key); 00077 00078 HTTPContent * SetOtherHeader(const char * key, const char * value); 00079 00080 void GetOtherHeaders(string * headers); 00081 00082 const char * GetBody(); 00083 00084 HTTPContent * SetBody(char * body, int offset, int length); 00085 00086 HTTPContent * ClearBody(); 00087 00088 int GetContentLength(); 00089 00090 }; 00091 } 00092 00093 #endif
Generated on Fri Jul 15 2022 01:02:11 by
1.7.2