Barracuda Application Server C/C++ Reference
NO
HttpResRdr.h
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Embedded Web-Server
10 *
11 ****************************************************************************
12 * HEADER
13 *
14 * $Id: HttpResRdr.h 5355 2022-11-16 10:33:45Z wini $
15 *
16 * COPYRIGHT: Real Time Logic LLC, 2006-2008
17 *
18 * This software is copyrighted by and is the sole property of Real
19 * Time Logic LLC. All rights, title, ownership, or other interests in
20 * the software remain the property of Real Time Logic LLC. This
21 * software may only be used in accordance with the terms and
22 * conditions stipulated in the corresponding license agreement under
23 * which the software has been supplied. Any unauthorized use,
24 * duplication, transmission, distribution, or disclosure of this
25 * software is expressly forbidden.
26 *
27 * This Copyright notice may not be removed or modified without prior
28 * written consent of Real Time Logic LLC.
29 *
30 * Real Time Logic LLC. reserves the right to modify this software
31 * without notice.
32 *
33 * http://www.realtimelogic.com
34 ****************************************************************************
35 *
36 *
37 */
38
39#ifndef _HttpResRdr_h
40#define _HttpResRdr_h
41
42#include "IoIntf.h"
43#include "BaServerLib.h"
44#include "HttpServer.h"
45
46
47struct HttpRdFilter;
48typedef void (*HttpRdFilter_Service)(struct HttpRdFilter* o,
49 const char* name,
50 IoStat* st,
51 HttpCommand* cmd);
52
56typedef struct HttpRdFilter
57{
58 DoubleLink super;
59 HttpRdFilter_Service serviceFp;
60 const char* ext; /* File Extension */
62
63BA_API void HttpRdFilter_constructor(
64 HttpRdFilter* o, const char* ext, HttpRdFilter_Service serviceFp);
65
66BA_API void HttpRdFilter_destructor(HttpRdFilter* o);
67
68/* Designed for LSP function dir:header(table)
69 The key and value indexes point to the key and value embedded as
70 part of the memory region below the struct.
71*/
72typedef struct {
73 U16 keyIx;
74 U16 valIx;
75} HttpResRdrHeader;
76
77
141typedef struct HttpResRdr
142#ifdef __cplusplus
143: public HttpDir
144{
145 HttpResRdr() {}
155 HttpResRdr(IoIntf* io, const char* dirName,
156 AllocatorIntf* alloc=0, S8 priority=0);
157
187 HttpResRdr(IoIntf* io, const char* domain, const char* p404,
188 AllocatorIntf* alloc=0, S8 priority=0);
189
202 int insertPrologDir(HttpDir* dir);
203
204 /* Terminate a HttpResRdr instance */
205 ~HttpResRdr();
206
209 int installFilter(HttpRdFilter* filter);
210
215 void setMaxAge(BaTime maxAge);
216
228 static void sendFile(
229 IoIntf* io,const char* name, IoStat* st, HttpCommand* cmd);
230
233 IoIntf* getIo();
234#if 0
235}
236#endif
237#else
238{
239 HttpDir super; /* Inherits from HttpDir */
240#endif
241 DoubleList filterList;
242 AllocatorIntf* alloc;
243 IoIntf* io;
244 HttpDir_Service superServiceFunc;
245 HttpDir* prologDirRoot;
246 HttpResRdrHeader* headers;
247 const char* domain;
248 const char* p404;
249 BaTime maxAge;
250 int maxFilterLen;
251} HttpResRdr;
252
253
254#ifdef __cplusplus
255extern "C" {
256#endif
257BA_API void HttpResRdr_constructor(
258 HttpResRdr* o, IoIntf* io, const char* dirName,
259 AllocatorIntf* alloc, S8 priority);
260BA_API void HttpResRdr_constructor2(
261 HttpResRdr* o,IoIntf* io,const char* domain,
262 const char* p404,AllocatorIntf* alloc,
263 S8 priority);
264BA_API int HttpResRdr_insertPrologDir(HttpResRdr* o, HttpDir* dir);
265BA_API void HttpResRdr_destructor(HttpResRdr* o);
266BA_API int HttpResRdr_installFilter(HttpResRdr* o, HttpRdFilter* filter);
267#define HttpResRdr_setMaxAge(o, maxAgeMA) (o)->maxAge=maxAgeMA
268#define HttpResRdr_setAuthenticator(o, authenticator, realm) \
269 HttpDir_setAuthenticator((HttpDir*)o, authenticator, realm)
270BA_API void HttpResRdr_sendFile(IoIntf* io,const char* name,
271 IoStat* st,HttpCommand* cmd);
272BA_API void set_deflategzip(IoIntf_DeflateGzip ptr);
273BA_API IoIntf_DeflateGzip get_deflategzip(void);
274BA_API void HttpResRdr_setHeader(HttpResRdr* o, HttpResRdrHeader* headers);
275
276
277#define HttpResRdr_getIo(o) (o)->io
278#ifdef __cplusplus
279}
280inline HttpResRdr::HttpResRdr(IoIntf* io, const char* domain, const char* p404,
281 AllocatorIntf* alloc, S8 priority) {
282 HttpResRdr_constructor2(this, io, domain, p404, alloc, priority);
283}
284inline HttpResRdr::HttpResRdr(IoIntf* io, const char* dirName,
285 AllocatorIntf* alloc, S8 priority) {
286 HttpResRdr_constructor(this, io, dirName, alloc, priority);
287}
288
290 return HttpResRdr_insertPrologDir(this, dir);
291}
292
293inline HttpResRdr::~HttpResRdr(){
294 HttpResRdr_destructor(this);
295}
297 return HttpResRdr_installFilter(this, filter);
298}
299inline void HttpResRdr::setMaxAge(BaTime maxAge){
300 HttpResRdr_setMaxAge(this, maxAge);
301}
303 IoIntf* io, const char* name, IoStat* st, HttpCommand* cmd){
304 HttpResRdr_sendFile(io,name,st,cmd);
305}
307 return HttpResRdr_getIo(this);
308}
309#endif
310
311
312#endif
ResIntfPtr(* IoIntf_DeflateGzip)(ResIntfPtr resPtr, const char *name, ThreadMutex *m, BaFileSize *size, BaBool *isCompressed)
Deflate a file or portion of a file to temporary storage.
Definition: IoIntf.h:269
int(* HttpDir_Service)(struct HttpDir *o, const char *relPath, HttpCommand *cmd)
The HttpDir service callback function.
Definition: HttpServer.h:2334
S64 BaTime
An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:10 GMT – i....
Definition: GenPrimT.h:93
Memory allocation and deallocation Interface class.
Definition: AllocatorIntf.h:83
The HttpCommand class is a container class for the HttpRequest and HttpResponse command pair.
Definition: HttpServer.h:1818
An instance of the HttpDir class, which is a collection of zero or more resources,...
Definition: HttpServer.h:2368
Superclass for HttpResRdr filters.
Definition: HttpResRdr.h:57
The HTTP resource reader searches and presents IoIntf resources to HTTP clients requesting such infor...
Definition: HttpResRdr.h:144
IoIntf * getIo()
Returns the IoIntf used by the HttpResRdr.
Definition: HttpResRdr.h:306
int insertPrologDir(HttpDir *dir)
Insert a prologue HttpDir.
Definition: HttpResRdr.h:289
int installFilter(HttpRdFilter *filter)
Install a filter.
Definition: HttpResRdr.h:296
static void sendFile(IoIntf *io, const char *name, IoStat *st, HttpCommand *cmd)
Send resource to a client.
Definition: HttpResRdr.h:302
void setMaxAge(BaTime maxAge)
Makes the HttpResRdr instance set the HTTP header "Cache-Control: max-age" for all resources.
Definition: HttpResRdr.h:299
The IoIntf class specifies an abstract file API, implementations include ZipIo, DiskIo,...
Definition: IoIntf.h:377
Resource information.
Definition: IoIntf.h:168