ESP8266
Classes | Public Types | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
ESP8266WebServer Class Reference

Classes

struct  RequestArgument
 

Public Types

typedef std::function< void(void)> THandlerFunction
 

Public Member Functions

 ESP8266WebServer (IPAddress addr, int port=80)
 
 ESP8266WebServer (int port=80)
 
 ~ESP8266WebServer ()
 
void begin ()
 
void handleClient ()
 
void close ()
 
void stop ()
 
bool authenticate (const char *username, const char *password)
 
void requestAuthentication ()
 
void on (const char *uri, THandlerFunction handler)
 
void on (const char *uri, HTTPMethod method, THandlerFunction fn)
 
void on (const char *uri, HTTPMethod method, THandlerFunction fn, THandlerFunction ufn)
 
void addHandler (RequestHandler *handler)
 
void serveStatic (const char *uri, fs::FS &fs, const char *path, const char *cache_header=NULL)
 
void onNotFound (THandlerFunction fn)
 
void onFileUpload (THandlerFunction fn)
 
String uri ()
 
HTTPMethod method ()
 
WiFiClient client ()
 
HTTPUploadupload ()
 
String arg (const char *name)
 
String arg (int i)
 
String argName (int i)
 
int args ()
 
bool hasArg (const char *name)
 
void collectHeaders (const char *headerKeys[], const size_t headerKeysCount)
 
String header (const char *name)
 
String header (int i)
 
String headerName (int i)
 
int headers ()
 
bool hasHeader (const char *name)
 
String hostHeader ()
 
void send (int code, const char *content_type=NULL, const String &content=String(""))
 
void send (int code, char *content_type, const String &content)
 
void send (int code, const String &content_type, const String &content)
 
void send_P (int code, PGM_P content_type, PGM_P content)
 
void send_P (int code, PGM_P content_type, PGM_P content, size_t contentLength)
 
void setContentLength (size_t contentLength)
 
void sendHeader (const String &name, const String &value, bool first=false)
 
void sendContent (const String &content)
 
void sendContent_P (PGM_P content)
 
void sendContent_P (PGM_P content, size_t size)
 
template<typename T >
size_t streamFile (T &file, const String &contentType)
 

Protected Member Functions

void _addRequestHandler (RequestHandler *handler)
 
void _handleRequest ()
 
bool _parseRequest (WiFiClient &client)
 
void _parseArguments (String data)
 
bool _parseForm (WiFiClient &client, String boundary, uint32_t len)
 
bool _parseFormUploadAborted ()
 
void _uploadWriteByte (uint8_t b)
 
uint8_t _uploadReadByte (WiFiClient &client)
 
void _prepareHeader (String &response, int code, const char *content_type, size_t contentLength)
 
bool _collectHeader (const char *headerName, const char *headerValue)
 
String urlDecode (const String &text)
 

Static Protected Member Functions

static const char * _responseCodeToString (int code)
 

Protected Attributes

WiFiServer _server
 
WiFiClient _currentClient
 
HTTPMethod _currentMethod
 
String _currentUri
 
RequestHandler_currentHandler
 
RequestHandler_firstHandler
 
RequestHandler_lastHandler
 
THandlerFunction _notFoundHandler
 
THandlerFunction _fileUploadHandler
 
int _currentArgCount
 
RequestArgument_currentArgs
 
HTTPUpload _currentUpload
 
int _headerKeysCount
 
RequestArgument_currentHeaders
 
size_t _contentLength
 
String _responseHeaders
 
String _hostHeader
 

Member Typedef Documentation

typedef std::function<void(void)> ESP8266WebServer::THandlerFunction

Constructor & Destructor Documentation

ESP8266WebServer::ESP8266WebServer ( IPAddress  addr,
int  port = 80 
)
ESP8266WebServer::ESP8266WebServer ( int  port = 80)
ESP8266WebServer::~ESP8266WebServer ( )

Member Function Documentation

void ESP8266WebServer::_addRequestHandler ( RequestHandler handler)
protected
bool ESP8266WebServer::_collectHeader ( const char *  headerName,
const char *  headerValue 
)
protected
void ESP8266WebServer::_handleRequest ( )
protected
void ESP8266WebServer::_parseArguments ( String  data)
protected
bool ESP8266WebServer::_parseForm ( WiFiClient client,
String  boundary,
uint32_t  len 
)
protected
bool ESP8266WebServer::_parseFormUploadAborted ( )
protected
bool ESP8266WebServer::_parseRequest ( WiFiClient client)
protected
void ESP8266WebServer::_prepareHeader ( String &  response,
int  code,
const char *  content_type,
size_t  contentLength 
)
protected
const char * ESP8266WebServer::_responseCodeToString ( int  code)
staticprotected
uint8_t ESP8266WebServer::_uploadReadByte ( WiFiClient client)
protected
void ESP8266WebServer::_uploadWriteByte ( uint8_t  b)
protected
void ESP8266WebServer::addHandler ( RequestHandler handler)
String ESP8266WebServer::arg ( const char *  name)
String ESP8266WebServer::arg ( int  i)
String ESP8266WebServer::argName ( int  i)
int ESP8266WebServer::args ( )
bool ESP8266WebServer::authenticate ( const char *  username,
const char *  password 
)
void ESP8266WebServer::begin ( )
WiFiClient ESP8266WebServer::client ( )
void ESP8266WebServer::close ( )
void ESP8266WebServer::collectHeaders ( const char *  headerKeys[],
const size_t  headerKeysCount 
)
void ESP8266WebServer::handleClient ( )
bool ESP8266WebServer::hasArg ( const char *  name)
bool ESP8266WebServer::hasHeader ( const char *  name)
String ESP8266WebServer::header ( const char *  name)
String ESP8266WebServer::header ( int  i)
String ESP8266WebServer::headerName ( int  i)
int ESP8266WebServer::headers ( )
String ESP8266WebServer::hostHeader ( )
HTTPMethod ESP8266WebServer::method ( )
void ESP8266WebServer::on ( const char *  uri,
ESP8266WebServer::THandlerFunction  handler 
)
void ESP8266WebServer::on ( const char *  uri,
HTTPMethod  method,
ESP8266WebServer::THandlerFunction  fn 
)
void ESP8266WebServer::on ( const char *  uri,
HTTPMethod  method,
ESP8266WebServer::THandlerFunction  fn,
ESP8266WebServer::THandlerFunction  ufn 
)
void ESP8266WebServer::onFileUpload ( THandlerFunction  fn)
void ESP8266WebServer::onNotFound ( THandlerFunction  fn)
void ESP8266WebServer::requestAuthentication ( )
void ESP8266WebServer::send ( int  code,
const char *  content_type = NULL,
const String &  content = String("") 
)
void ESP8266WebServer::send ( int  code,
char *  content_type,
const String &  content 
)
void ESP8266WebServer::send ( int  code,
const String &  content_type,
const String &  content 
)
void ESP8266WebServer::send_P ( int  code,
PGM_P  content_type,
PGM_P  content 
)
void ESP8266WebServer::send_P ( int  code,
PGM_P  content_type,
PGM_P  content,
size_t  contentLength 
)
void ESP8266WebServer::sendContent ( const String &  content)
void ESP8266WebServer::sendContent_P ( PGM_P  content)
void ESP8266WebServer::sendContent_P ( PGM_P  content,
size_t  size 
)
void ESP8266WebServer::sendHeader ( const String &  name,
const String &  value,
bool  first = false 
)
void ESP8266WebServer::serveStatic ( const char *  uri,
fs::FS fs,
const char *  path,
const char *  cache_header = NULL 
)
void ESP8266WebServer::setContentLength ( size_t  contentLength)
void ESP8266WebServer::stop ( )
template<typename T >
size_t ESP8266WebServer::streamFile ( T &  file,
const String &  contentType 
)
HTTPUpload& ESP8266WebServer::upload ( )
String ESP8266WebServer::uri ( )
String ESP8266WebServer::urlDecode ( const String &  text)
protected

Member Data Documentation

size_t ESP8266WebServer::_contentLength
protected
int ESP8266WebServer::_currentArgCount
protected
RequestArgument* ESP8266WebServer::_currentArgs
protected
WiFiClient ESP8266WebServer::_currentClient
protected
RequestHandler* ESP8266WebServer::_currentHandler
protected
RequestArgument* ESP8266WebServer::_currentHeaders
protected
HTTPMethod ESP8266WebServer::_currentMethod
protected
HTTPUpload ESP8266WebServer::_currentUpload
protected
String ESP8266WebServer::_currentUri
protected
THandlerFunction ESP8266WebServer::_fileUploadHandler
protected
RequestHandler* ESP8266WebServer::_firstHandler
protected
int ESP8266WebServer::_headerKeysCount
protected
String ESP8266WebServer::_hostHeader
protected
RequestHandler* ESP8266WebServer::_lastHandler
protected
THandlerFunction ESP8266WebServer::_notFoundHandler
protected
String ESP8266WebServer::_responseHeaders
protected
WiFiServer ESP8266WebServer::_server
protected