Barracuda Application Server C/C++ Reference
NO
MultipartUpload.h
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Embedded Web-Server
10 *
11 ****************************************************************************
12 * HEADER
13 *
14 * $Id: MultipartUpload.h 5387 2023-02-20 22:50:13Z wini $
15 *
16 * COPYRIGHT: Real Time Logic LLC, 2006 - 2023
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 __HttpMultipartUpload_h
40#define __HttpMultipartUpload_h
41
42#include "HttpServer.h"
43#include "BaServerLib.h"
44
54typedef enum
55{
56 MultipartUpload_NoError=0,
57 MultipartUpload_ConnectionTerminated=-100,
58 MultipartUpload_NoMemory,
59 MultipartUpload_ParseError1,
60 MultipartUpload_ParseError2,
61 MultipartUpload_ParseError3,
62 MultipartUpload_ParseError4,
63 MultipartUpload_ParseError5,
64 MultipartUpload_ParseError6,
65 MultipartUpload_UserRetErr
67
68#ifndef __DOXYGEN__
69struct MultipartUpload;
70#endif
71
79 struct MultipartUpload* o);
80
81
96 struct MultipartUpload* o,
97 const char* name,
98 const char* value);
99
117 struct MultipartUpload* o,
118 const char* name,
119 const char* fileName,
120 const char* contentType,
121 const char* contentTransferEncoding);
122
136 struct MultipartUpload* o,
137 const U8* data,
138 U16 len);
139
146typedef void (*MultipartUpload_Error)(
147 struct MultipartUpload* o,
149
150
151
152typedef enum {
153 MultipartUpload_ReadBoundaryTag,
154 MultipartUpload_ReadHeaders,
155 MultipartUpload_ReadFormData,
156 MultipartUpload_ReadFileData
157} MultipartUpload_States;
158
159
187typedef struct MultipartUpload
188{
189#ifdef __cplusplus
190 MultipartUpload() {}
191
223 MultipartUpload_EndOfReq onEndOfReq,
224 MultipartUpload_FormData onFormData,
225 MultipartUpload_FileBegin onFileBegin,
226 MultipartUpload_FileData onFileData,
227 MultipartUpload_Error onError,
228 U32 bufferSize,
229 AllocatorIntf* allocator = 0);
230
233
242 int start(HttpRequest *req);
243
244
245 int run(HttpRequest *req, bool setKeepAlive=true);
246
260
264
265 private:
266#endif
267 HttpConnection super; /* Inherits from HttpConnection */
268
269 /* List used as a stack, containing Boundary tags. */
270 DoubleList boundaryStack;
275 MultipartUpload_Error onError;
276 HttpConnection* con; /* Set if in blocking mode. NULL for asynch mode. */
277 char* dataBuffer;
278 char* name;
279 char* fileName;
280 char* contentType;
281 char* contentTransferEncoding;
282 char* currBName;
283 AllocatorIntf* alloc;
284 MultipartUpload_States state;
285 U32 currentI;
286 U32 readI;
287 U32 lineStartI;
288 U32 lineEndI;
289 U32 dataBufferSize;
290 U32 expandSize;
291 U32 maxFormSize;
292 BaBool newBoundaryTag;
293 BaBool copyingHttpReqData;
295
296
297#ifdef __cplusplus
298extern "C" {
299#endif
300void
301BA_API MultipartUpload_constructor(
303 HttpServer* server,
308 MultipartUpload_Error onError,
309 U32 bufferSize,
310 AllocatorIntf* allocator);
311BA_API void MultipartUpload_destructor(MultipartUpload* o);
312BA_API int MultipartUpload_start(MultipartUpload* o, HttpRequest *req);
313BA_API int MultipartUpload_run(
314 MultipartUpload* o, HttpRequest *req, BaBool setKeepAlive);
315BA_API HttpConnection* MultipartUpload_getCon(MultipartUpload* o);
316#define MultipartUpload_getServer(o) \
317 HttpConnection_getServer((HttpConnection*)(o))
318#ifdef __cplusplus
319}
320inline MultipartUpload::MultipartUpload(
321 HttpServer* server,
326 MultipartUpload_Error onError,
327 U32 size,
328 AllocatorIntf* allocator) {
329 MultipartUpload_constructor(this, server, endOfReq, formData,
330 fileBegin, fileData, onError, size, allocator);
331}
333 MultipartUpload_destructor(this);
334}
336 return MultipartUpload_start(this,req);
337}
338inline int MultipartUpload::run(HttpRequest *req, bool setKeepAlive) {
339 return MultipartUpload_run(this,req,setKeepAlive?TRUE:FALSE);
340}
342 return MultipartUpload_getCon(this); }
344 return MultipartUpload_getServer(this);
345}
346#endif
347 /* end of HttpStack */
349
350
351#endif
struct MultipartUpload MultipartUpload
The MultipartUpload, which is an abstract base class, implements the functionality as specified in RF...
int(* MultipartUpload_FileData)(struct MultipartUpload *o, const U8 *data, U16 len)
Executed by MultipartUpload when a data chunk is available.
Definition: MultipartUpload.h:135
HttpConnection * getCon(MultipartUpload *o)
Returns the internal active connection object.
Definition: MultipartUpload.h:341
~MultipartUpload()
Release buffers used during parsing the multipart stream.
Definition: MultipartUpload.h:332
void(* MultipartUpload_EndOfReq)(struct MultipartUpload *o)
Executed by MultipartUpload when a multipart upload is completed.
Definition: MultipartUpload.h:78
int(* MultipartUpload_FormData)(struct MultipartUpload *o, const char *name, const char *value)
Executed by MultipartUpload every time a form data element such as "text" is found in the multipart d...
Definition: MultipartUpload.h:95
void(* MultipartUpload_Error)(struct MultipartUpload *o, MultipartUpload_ErrorType e)
Executed by MultipartUpload if any errors are detected during parsing of the multipart data stream.
Definition: MultipartUpload.h:146
HttpServer * getServer()
Get the HttpServer instance.
Definition: MultipartUpload.h:343
int(* MultipartUpload_FileBegin)(struct MultipartUpload *o, const char *name, const char *fileName, const char *contentType, const char *contentTransferEncoding)
Executed by MultipartUpload when a file is found in the multipart data stream.
Definition: MultipartUpload.h:116
MultipartUpload_ErrorType
Error codes used by the callback function MultipartUpload_Error in interface class MultipartUpload.
Definition: MultipartUpload.h:55
int start(HttpRequest *req)
Start receiving data asynchronously.
Definition: MultipartUpload.h:335
Memory allocation and deallocation Interface class.
Definition: AllocatorIntf.h:83
Contains information about the physical socket connection.
Definition: HttpConnection.h:76
The HttpServer creates an HttpRequest object when the HttpServer parses a client request.
Definition: HttpServer.h:808
The Web Server.
Definition: HttpServer.h:2864
The MultipartUpload, which is an abstract base class, implements the functionality as specified in RF...
Definition: MultipartUpload.h:188