Prusa MINI Firmware overview
FileResponse Class Reference

Class to response any static files defined in files array. More...

Inheritance diagram for FileResponse:
Collaboration diagram for FileResponse:

Public Member Functions

 FileResponse (const FileHandler_t *handler)
 
virtual Message_t generator (const struct pbuf *input=nullptr) override
 Response generator, iterative returns file data. More...
 
- Public Member Functions inherited from IResponse
 IResponse (const IResponse &)=delete
 
 IResponse ()
 
- Public Member Functions inherited from LwIPClass
virtual ~LwIPClass ()
 

Additional Inherited Members

- Public Types inherited from IResponse
typedef std::unique_ptr< IResponseunique_ptr_t
 
- Static Public Member Functions inherited from LwIPClass
static voidoperator new (size_t size)
 
static void operator delete (void *ptr)
 

Detailed Description

Class to response any static files defined in files array.

Constructor & Destructor Documentation

◆ FileResponse()

FileResponse::FileResponse ( const FileHandler_t handler)
95  : handler(handler)
96  , ct_header("Content-Type", handler->content_type, &cl_header)
97  , cl_header("Content-Length", handler->content_length, &lm_header)
98  , lm_header("Last-Modify", last_modified, &cc_header)
99  , cc_header("Cache-Control", "public, max-age=31536000")
100  , done(false) {}

Member Function Documentation

◆ generator()

Message_t FileResponse::generator ( const struct pbuf input = nullptr)
overridevirtual

Response generator, iterative returns file data.

Implements IResponse.

106  {
107  Message_t msg = { nullptr, nullptr, nullptr, EOF };
108 
109  if (!done) {
110  msg = (Message_t) { HTTP_200, &ct_header, handler->data, handler->content_length };
111  done = true;
112  }
113  return msg;
114 }
FileHandler_t::content_type
const char * content_type
Definition: connect.cpp:46
HTTP_200
const char * HTTP_200
Definition: http_states.c:3
Message_t
Message which must be returned from coroutine generator.
Definition: lwsapi_app.hpp:211
EOF
#define EOF
Definition: ff.h:286
FileHandler_t::content_length
int content_length
Definition: connect.cpp:47
FileHandler_t::data
const uint8_t * data
Definition: connect.cpp:48