Arduino DLNA Server
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tiny_dlna::HttpServer< ClientType, ServerType > Class Template Reference

Header-only HTTP server wrapper that registers callback handlers. More...

#include <HttpServer.h>

Inheritance diagram for tiny_dlna::HttpServer< ClientType, ServerType >:
Inheritance graph
[legend]

Public Member Functions

 HttpServer (ServerType &server, int bufferSize=1024)
 
 ~HttpServer () override
 
IPAddress & localIP () override
 Provides the local ip address.
 
bool begin () override
 Starts the server.
 
void end () override
 stops the server_ptr
 
void rewrite (const char *from, const char *to) override
 adds a rewrite rule
 
void on (const char *url, TinyMethodID method, web_callback_fn fn, void *ctx[]=nullptr, int ctxCount=0) override
 register a generic handler
 
void on (const char *url, TinyMethodID method, const char *mime, web_callback_fn fn) override
 register a handler with mime
 
void on (const char *url, TinyMethodID method, const char *mime, const char *result) override
 register a handler which provides the indicated string
 
void on (const char *url, TinyMethodID method, const char *mime, const uint8_t *data, int len) override
 register a handler which provides the indicated string
 
void on (const char *url, TinyMethodID method, Url &redirect) override
 register a redirection
 
bool onRequest (const char *path) override
 
void addHandler (HttpRequestHandlerLine *handlerLinePtr)
 adds a new handler
 
bool doLoop () override
 Legacy method: same as copy();.
 
bool copy () override
 Call this method from your loop!
 
 operator bool () override
 Provides true if the server has been started.
 
bool isActive () override
 
const char * localHost () override
 Determines the local ip address.
 
void setNoConnectDelay (int delay) override
 
void setReference (void *reference) override
 Definesa reference/context object.
 
void * getReference () override
 Provides access to a reference/context object.
 

Protected Member Functions

void removeClosedClients ()
 
const char * nullstr (const char *in)
 
void processRequest (ClientType *p_client)
 
const char * resolveRewrite (const char *from)
 
bool matchesMime (const char *handler_mime, const char *request_mime)
 

Protected Attributes

List< HttpRequestHandlerLine * > handler_collection
 
List< HttpRequestRewrite * > rewrite_collection
 
ListLockFree< ClientType > open_clients
 
HttpClientHandler< ClientType > client_handler
 
ListLockFree< ClientType >::Iterator current_client_iterator
 
ServerType * server_ptr = nullptr
 
bool is_active
 
const char * local_host = nullptr
 
int no_connect_delay = 5
 
void * ref = nullptr
 

Detailed Description

template<typename ClientType, typename ServerType>
class tiny_dlna::HttpServer< ClientType, ServerType >

Header-only HTTP server wrapper that registers callback handlers.

This server is templated so you can provide the concrete Arduino networking classes that back the transport. ClientType is the socket implementation accepted from the server (for example WiFiClient or EthernetClient) and ServerType is the listener type (for example WiFiServer). Default template arguments keep the legacy WiFi behaviour intact, while custom transports can swap in their own client/server types.

Template Parameters
ClientTypeArduino client class accepted from the listener (e.g. WiFiClient, EthernetClient).
ServerTypeArduino server/listener class that produces ClientType instances (e.g. WiFiServer, EthernetServer).

Constructor & Destructor Documentation

◆ HttpServer()

template<typename ClientType , typename ServerType >
tiny_dlna::HttpServer< ClientType, ServerType >::HttpServer ( ServerType &  server,
int  bufferSize = 1024 
)
inline

◆ ~HttpServer()

template<typename ClientType , typename ServerType >
tiny_dlna::HttpServer< ClientType, ServerType >::~HttpServer ( )
inlineoverride

Member Function Documentation

◆ addHandler()

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::addHandler ( HttpRequestHandlerLine handlerLinePtr)
inlinevirtual

adds a new handler

Implements tiny_dlna::IHttpServer.

◆ begin()

template<typename ClientType , typename ServerType >
bool tiny_dlna::HttpServer< ClientType, ServerType >::begin ( )
inlineoverridevirtual

Starts the server.

Implements tiny_dlna::IHttpServer.

◆ copy()

template<typename ClientType , typename ServerType >
bool tiny_dlna::HttpServer< ClientType, ServerType >::copy ( )
inlineoverridevirtual

Call this method from your loop!

Implements tiny_dlna::IHttpServer.

◆ doLoop()

template<typename ClientType , typename ServerType >
bool tiny_dlna::HttpServer< ClientType, ServerType >::doLoop ( )
inlineoverridevirtual

Legacy method: same as copy();.

Implements tiny_dlna::IHttpServer.

◆ end()

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::end ( )
inlineoverridevirtual

stops the server_ptr

Implements tiny_dlna::IHttpServer.

◆ getReference()

template<typename ClientType , typename ServerType >
void * tiny_dlna::HttpServer< ClientType, ServerType >::getReference ( )
inlineoverridevirtual

Provides access to a reference/context object.

Implements tiny_dlna::IHttpServer.

◆ isActive()

template<typename ClientType , typename ServerType >
bool tiny_dlna::HttpServer< ClientType, ServerType >::isActive ( )
inlineoverridevirtual

◆ localHost()

template<typename ClientType , typename ServerType >
const char * tiny_dlna::HttpServer< ClientType, ServerType >::localHost ( )
inlineoverridevirtual

Determines the local ip address.

Implements tiny_dlna::IHttpServer.

◆ localIP()

template<typename ClientType , typename ServerType >
IPAddress & tiny_dlna::HttpServer< ClientType, ServerType >::localIP ( )
inlineoverridevirtual

Provides the local ip address.

Implements tiny_dlna::IHttpServer.

◆ matchesMime()

template<typename ClientType , typename ServerType >
bool tiny_dlna::HttpServer< ClientType, ServerType >::matchesMime ( const char *  handler_mime,
const char *  request_mime 
)
inlineprotected

compares mime of handler with mime of request: provides true if they match or one is null (=any value)

◆ nullstr()

template<typename ClientType , typename ServerType >
const char * tiny_dlna::HttpServer< ClientType, ServerType >::nullstr ( const char *  in)
inlineprotected

◆ on() [1/5]

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::on ( const char *  url,
TinyMethodID  method,
const char *  mime,
const char *  result 
)
inlineoverridevirtual

register a handler which provides the indicated string

Implements tiny_dlna::IHttpServer.

◆ on() [2/5]

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::on ( const char *  url,
TinyMethodID  method,
const char *  mime,
const uint8_t *  data,
int  len 
)
inlineoverridevirtual

register a handler which provides the indicated string

Implements tiny_dlna::IHttpServer.

◆ on() [3/5]

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::on ( const char *  url,
TinyMethodID  method,
const char *  mime,
web_callback_fn  fn 
)
inlineoverridevirtual

register a handler with mime

Implements tiny_dlna::IHttpServer.

◆ on() [4/5]

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::on ( const char *  url,
TinyMethodID  method,
Url redirect 
)
inlineoverridevirtual

register a redirection

Implements tiny_dlna::IHttpServer.

◆ on() [5/5]

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::on ( const char *  url,
TinyMethodID  method,
web_callback_fn  fn,
void *  ctx[] = nullptr,
int  ctxCount = 0 
)
inlineoverridevirtual

register a generic handler

Implements tiny_dlna::IHttpServer.

◆ onRequest()

template<typename ClientType , typename ServerType >
bool tiny_dlna::HttpServer< ClientType, ServerType >::onRequest ( const char *  path)
inlineoverridevirtual

generic handler - you can overwrite this method to provide your specifc processing logic

Implements tiny_dlna::IHttpServer.

◆ operator bool()

template<typename ClientType , typename ServerType >
tiny_dlna::HttpServer< ClientType, ServerType >::operator bool ( )
inlineoverridevirtual

Provides true if the server has been started.

Implements tiny_dlna::IHttpServer.

◆ processRequest()

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::processRequest ( ClientType *  p_client)
inlineprotected

◆ removeClosedClients()

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::removeClosedClients ( )
inlineprotected

◆ resolveRewrite()

template<typename ClientType , typename ServerType >
const char * tiny_dlna::HttpServer< ClientType, ServerType >::resolveRewrite ( const char *  from)
inlineprotected

determiens the potentially rewritten url which should be used for the further processing

◆ rewrite()

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::rewrite ( const char *  from,
const char *  to 
)
inlineoverridevirtual

adds a rewrite rule

Implements tiny_dlna::IHttpServer.

◆ setNoConnectDelay()

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::setNoConnectDelay ( int  delay)
inlineoverridevirtual

◆ setReference()

template<typename ClientType , typename ServerType >
void tiny_dlna::HttpServer< ClientType, ServerType >::setReference ( void *  reference)
inlineoverridevirtual

Definesa reference/context object.

Implements tiny_dlna::IHttpServer.

Member Data Documentation

◆ client_handler

template<typename ClientType , typename ServerType >
HttpClientHandler<ClientType> tiny_dlna::HttpServer< ClientType, ServerType >::client_handler
protected

◆ current_client_iterator

template<typename ClientType , typename ServerType >
ListLockFree<ClientType>::Iterator tiny_dlna::HttpServer< ClientType, ServerType >::current_client_iterator
protected
Initial value:
=
ListLockFree< ClientType > open_clients
Definition: HttpServer.h:335
Iterator begin()
Definition: ListLockFree.h:388

◆ handler_collection

template<typename ClientType , typename ServerType >
List<HttpRequestHandlerLine*> tiny_dlna::HttpServer< ClientType, ServerType >::handler_collection
protected

◆ is_active

template<typename ClientType , typename ServerType >
bool tiny_dlna::HttpServer< ClientType, ServerType >::is_active
protected

◆ local_host

template<typename ClientType , typename ServerType >
const char* tiny_dlna::HttpServer< ClientType, ServerType >::local_host = nullptr
protected

◆ no_connect_delay

template<typename ClientType , typename ServerType >
int tiny_dlna::HttpServer< ClientType, ServerType >::no_connect_delay = 5
protected

◆ open_clients

template<typename ClientType , typename ServerType >
ListLockFree<ClientType> tiny_dlna::HttpServer< ClientType, ServerType >::open_clients
protected

◆ ref

template<typename ClientType , typename ServerType >
void* tiny_dlna::HttpServer< ClientType, ServerType >::ref = nullptr
protected

◆ rewrite_collection

template<typename ClientType , typename ServerType >
List<HttpRequestRewrite*> tiny_dlna::HttpServer< ClientType, ServerType >::rewrite_collection
protected

◆ server_ptr

template<typename ClientType , typename ServerType >
ServerType* tiny_dlna::HttpServer< ClientType, ServerType >::server_ptr = nullptr
protected

The documentation for this class was generated from the following file: