httpfile

httpfile is a class used by the IWebserverPlugin to realize static files. A static file that will be provided by the IWebserverPlugin needs to converted with the httpfiles tool and added to the project during the building process (have a look to an innovaphone App created from the template within Visual Studio to see how to implement static files). Each file that will be statically included will be represented by an httpfile instance and placed inside a btree. So generally there is no need to use the httpfile class "manually".
NOTE: The interface of httpfile is compatible to the innovaphone firmware internals.

File information

Filecommon/interface/httpfile.h

Classes httpfile

Static Variables staticFilesRoot

Classes

httpfile

class httpfile: public btree {
public:
    httpfile(const char * fileName, word /* servlettype unused */, word theFlags, byte * data, size_t dataSize);
    ~httpfile();

    const char * GetFileName() { return fileName; }
    const byte * GetData() { return data; }
    size_t GetSize() { return dataSize; }
    word GetResourceType() { return type; }
    word GetFlags() { return flags; }
    const char * GetMD5String() { return md5str; }
};

Public functions

httpfile (Constructor)

Parameters

const char * fileNameThe name of the static file including the path to the file a path inside the virtual web directory of an app registered to the webserver (e. G. "/main/index.html")
word <unused>Unused on the AppPlatform side. This parameter only exists for compatibility reasons with other innovaphone projects. Set always to 0.
word theFlagsFlags for the file. Currently ond one flag exist (HTTP_GZIP) to declare the file as stored in compressed format.
byte * dataPointer to the data of the file.
size_t dataSizeThe size of the data.

Remarks

If the file is compressed, the webserver will handle the necessary header fields need by the browser.
GetFileName

Return Value

Returns the name of the file including the path (like set with the fileName parameter of the constructor).
GetFileName

Return Value

Returns a pointer to the file date.
GetSize

Return Value

Returns the size of the file. If the file is compressed, the file size is in compressed state.
GetResourceType

Return Value

Returns the resource type of the file. That value will send from the webbrowser as content-type header field. The constructor of httpfile autodetecst the resource type by the file suffix.
GetFlags

Return Value

Returns the flags set for the file. For now, only HTTP_GZIP is supported to indicate, that the file data is in gzip compressed format.
GetMD5String

Return Value

Returns the MD5 checksum of the file date. This value will be calculated by the constructor and used by the IWebserverPlugin / Webserver as etag to support file caching of the browser.

Static Variables

staticFilesRoot

All httpfile instances are put to the staticFilesRoot btree for fast accessing them when requested. Don't manipulate that btree, it will completly be managed by the httpfile instances themselfs and accessed by the IWebserverPlugin.