Patrick Barrett / HTTPClient

Dependencies:   CyaSSL

Dependents:   exosite_http_example exosite_http_example

Fork of HTTPClient by wolf SSL

Embed: (wiki syntax)

« Back to documentation index

HTTPMap Class Reference

Map of key/value pairs Used to transmit POST data using the application/x-www-form-urlencoded encoding. More...

#include <HTTPMap.h>

Inherits IHTTPDataIn, and IHTTPDataOut.

Public Member Functions

 HTTPMap ()
 Instantiates HTTPMap It supports at most 32 key/values pairs.
 HTTPMap (char *buf, size_t size)
 Create an HTTPMap instance for input.
void put (const char *key, const char *value)
 Put Key/Value pair The references to the parameters must remain valid as long as the clear() function is not called.
bool pop (char *&key, char *&value)
 Pop one Key/Value pair The returned refrences remain valid as long as the original buffer is not modified.
bool get (const char *key, char *val_buf, const size_t max)
 Get Value specified in Key The value is copied into the provided buffer.
void clear ()
 Clear table.

Protected Member Functions

virtual void readReset ()
 Reset stream to its beginning Called by the HTTPClient on each new request.
virtual int read (char *buf, size_t len, size_t *pReadLen)
 Read a piece of data to be transmitted.
virtual int getDataType (char *type, size_t maxTypeLen)
 Get MIME type.
virtual bool getIsChunked ()
 Determine whether the HTTP client should chunk the data Used for Transfer-Encoding header.
virtual size_t getDataLen ()
 If the data is not chunked, get its size Used for Content-Length header.
virtual void writeReset ()
 Reset stream to its beginning Called by the HTTPClient on each new request.
virtual int write (const char *buf, size_t len)
 Write a piece of data transmitted by the server.
virtual void setDataType (const char *type)
 Set MIME type.
virtual void setIsChunked (bool chunked)
 Determine whether the data is chunked Recovered from Transfer-Encoding header.
virtual void setDataLen (size_t len)
 If the data is not chunked, set its size From Content-Length header.

Friends

class HTTPClient
class HTTPClient

Detailed Description

Map of key/value pairs Used to transmit POST data using the application/x-www-form-urlencoded encoding.

Definition at line 31 of file HTTPMap.h.


Constructor & Destructor Documentation

HTTPMap (  )

Instantiates HTTPMap It supports at most 32 key/values pairs.

Definition at line 37 of file HTTPMap.cpp.

HTTPMap ( char *  buf,
size_t  size 
)

Create an HTTPMap instance for input.

Parameters:
strBuffer to store the incoming string
sizeSize of the buffer

Definition at line 42 of file HTTPMap.cpp.


Member Function Documentation

void clear (  )

Clear table.

Definition at line 58 of file HTTPMap.cpp.

bool get ( const char *  key,
char *  val_buf,
const size_t  max 
)

Get Value specified in Key The value is copied into the provided buffer.

Parameters:
keyThe key of the value to get
val_bufThe output buffer into which the value will be copied
maxThe size of the buffer
lenThe number of bytes copied into the output buffer

Definition at line 279 of file HTTPMap.cpp.

size_t getDataLen (  ) [protected, virtual]

If the data is not chunked, get its size Used for Content-Length header.

Implements IHTTPDataOut.

Definition at line 162 of file HTTPMap.cpp.

int getDataType ( char *  type,
size_t  maxTypeLen 
) [protected, virtual]

Get MIME type.

Parameters:
typeInternet media type from Content-Type header

Implements IHTTPDataOut.

Definition at line 150 of file HTTPMap.cpp.

bool getIsChunked (  ) [protected, virtual]

Determine whether the HTTP client should chunk the data Used for Transfer-Encoding header.

Implements IHTTPDataOut.

Definition at line 157 of file HTTPMap.cpp.

bool pop ( char *&  key,
char *&  value 
)

Pop one Key/Value pair The returned refrences remain valid as long as the original buffer is not modified.

Parameters:
keyThe key
valueThe corresponding value

Definition at line 245 of file HTTPMap.cpp.

void put ( const char *  key,
const char *  value 
)

Put Key/Value pair The references to the parameters must remain valid as long as the clear() function is not called.

Parameters:
keyThe key to use
valueThe corresponding value

Definition at line 47 of file HTTPMap.cpp.

int read ( char *  buf,
size_t  len,
size_t *  pReadLen 
) [protected, virtual]

Read a piece of data to be transmitted.

Parameters:
bufPointer to the buffer on which to copy the data
lenLength of the buffer
pReadLenPointer to the variable on which the actual copied data length will be stored

Implements IHTTPDataOut.

Definition at line 69 of file HTTPMap.cpp.

void readReset (  ) [protected, virtual]

Reset stream to its beginning Called by the HTTPClient on each new request.

Implements IHTTPDataOut.

Definition at line 64 of file HTTPMap.cpp.

void setDataLen ( size_t  len ) [protected, virtual]

If the data is not chunked, set its size From Content-Length header.

Implements IHTTPDataIn.

Definition at line 239 of file HTTPMap.cpp.

void setDataType ( const char *  type ) [protected, virtual]

Set MIME type.

Parameters:
typeInternet media type from Content-Type header

Implements IHTTPDataIn.

Definition at line 229 of file HTTPMap.cpp.

void setIsChunked ( bool  chunked ) [protected, virtual]

Determine whether the data is chunked Recovered from Transfer-Encoding header.

Implements IHTTPDataIn.

Definition at line 234 of file HTTPMap.cpp.

int write ( const char *  buf,
size_t  len 
) [protected, virtual]

Write a piece of data transmitted by the server.

Parameters:
bufPointer to the buffer from which to copy the data
lenLength of the buffer

Implements IHTTPDataIn.

Definition at line 220 of file HTTPMap.cpp.

void writeReset (  ) [protected, virtual]

Reset stream to its beginning Called by the HTTPClient on each new request.

Implements IHTTPDataIn.

Definition at line 215 of file HTTPMap.cpp.