Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
HttpParameter Struct Reference

Detailed Description

A persistent container object for HTTP parameters.

The parameters in an HttpRequest object are valid only for the duration of the call. The HttpParameter is a container object for the parameters. One can clone the parameters in the request object and save the parameters in an HttpParameter object.

C example:

request);
if(param)
{
// Use the copied parameters, then release their allocation.
baFree(param);
}
BA_API HttpParameter * HttpParameter_clone(void *buf, struct HttpRequest *req)
Copy HTTP parameters to buf and return as a HttpParameter object.
BA_API U32 HttpParameter_calculateSize(struct HttpRequest *req)
Calculate the HttpParameter size.
void * baMalloc(size_t size)
Allocate uninitialized storage using the target's configured allocator.
void baFree(void *p)
Release storage using the target's configured allocator.
A persistent container object for HTTP parameters.
Definition: HttpServer.h:389

C++ example:

request);
if(param)
{
// Use the copied parameters, then release their allocation.
baFree(param);
}
static U32 calculateSize(struct HttpRequest *req)
Calculate the HttpParameter size.
Definition: HttpServer.h:448
static HttpParameter * clone(void *buf, struct HttpRequest *req)
Copy HTTP parameters to buf and return as a HttpParameter object.
Definition: HttpServer.h:450

All parameters are contained within one memory unit and one can simply call baFree(param) when the object is no longer needed.

You use the HttpParameterIterator for iterating the elements in the object.

C example:

if(param)
{
for(;
HttpParameterIterator_hasMoreElements(&i) ;
HttpParameterIterator_nextElement(&i))
{
HttpTrace_printf(0,"Param: %s = %s\n", i.name, i.value);
}
baFree(param);
}
BA_API void HttpTrace_printf(int prio, const char *fmt,...)
Write data to the trace buffer.
BA_API int HttpParameterIterator_constructor2(HttpParameterIterator *o, HttpParameter *param)
Initialize an iterator and select its first element.
The HttpParameterIterator is used for iterating through the form elements parsed by the HttpServer ob...
Definition: HttpServer.h:485

C++ Example: See HttpParameterIterator.

#include <HttpServer.h>

Public Member Functions

const char * getParameter (const char *paramName)
 Returns the value of a request parameter as a const char*, or null if the parameter does not exist. More...
 

Static Public Member Functions

static U32 calculateSize (struct HttpRequest *req)
 Calculate the HttpParameter size. More...
 
static HttpParameterclone (void *buf, struct HttpRequest *req)
 Copy HTTP parameters to buf and return as a HttpParameter object. More...
 

Member Function Documentation

◆ calculateSize()

U32 HttpParameter::calculateSize ( struct HttpRequest req)
static

Calculate the HttpParameter size.

Parameters
reqRequired live request.
Returns
Bytes for a clone, or zero when no parameters exist. For an empty clone, still provide at least sizeof(HttpParameter) bytes.

◆ clone()

HttpParameter * HttpParameter::clone ( void *  buf,
struct HttpRequest req 
)
static

Copy HTTP parameters to buf and return as a HttpParameter object.

Parameters
bufWritable, suitably aligned storage of at least calculateSize(req) bytes, and at least sizeof(HttpParameter) even for an empty request. NULL is accepted and returns NULL; no allocation occurs here.
reqRequired live request; strings are copied.
Returns
buf as a container pointer, or NULL for NULL buf. The clone is independent of the request. The caller retains allocation ownership.

◆ getParameter()

const char * HttpParameter::getParameter ( const char *  paramName)

Returns the value of a request parameter as a const char*, or null if the parameter does not exist.

Request parameters are extra information sent with the request, which are contained in the query string or posted form data.

If you use this method with a multivalued parameter, the value returned is equal to the first value in a HttpParameterIterator.

Parameters
paramNameRequired NUL-terminated, case-sensitive parameter name.
Returns
Borrowed value in this container, or NULL when absent; valid until the container storage is released.