A Port of TI's Webserver for the CC3000

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers HttpStatic.h Source File

HttpStatic.h

00001 /*****************************************************************************
00002 *
00003 *  HttpStatic.h
00004 *  Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
00005 *
00006 *  Redistribution and use in source and binary forms, with or without
00007 *  modification, are permitted provided that the following conditions
00008 *  are met:
00009 *
00010 *    Redistributions of source code must retain the above copyright
00011 *    notice, this list of conditions and the following disclaimer.
00012 *
00013 *    Redistributions in binary form must reproduce the above copyright
00014 *    notice, this list of conditions and the following disclaimer in the
00015 *    documentation and/or other materials provided with the   
00016 *    distribution.
00017 *
00018 *    Neither the name of Texas Instruments Incorporated nor the names of
00019 *    its contributors may be used to endorse or promote products derived
00020 *    from this software without specific prior written permission.
00021 *
00022 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00023 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
00024 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00025 *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
00026 *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
00027 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
00028 *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00029 *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00030 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00031 *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00032 *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 *
00034 *****************************************************************************/
00035 #ifndef _HTTP_STATIC_H_
00036 #define _HTTP_STATIC_H_
00037 
00038 #include "HttpConfig.h"
00039 
00040 #ifdef HTTP_CORE_ENABLE_STATIC
00041 
00042 /** 
00043  * @defgroup HttpStatic Static request handler module
00044  * This module implements static content processing for HTTP requests.
00045  * All requests are handled by looking up the URL's resource in the flash database, and returning the content in the response.
00046  * Note this module is only compiled if HTTP_CORE_ENABLE_STATIC is defined in HttpConfig.h
00047  *
00048  * @{
00049  */
00050 
00051 #include "HttpRequest.h"
00052 
00053 /**
00054  * Initialize HttpStatic module state for a new request, and identify the request
00055  * This function examines the specified resource string, and looks it up in the Flash Database.
00056  * Note: During FlashDB lookup, ignore the query part (?) and anchor part (#) of URL
00057  * If found, it commits to process this request by returning nonzero. Otherwise it returns zero.
00058  * @param uConnection The number of the connection. This value is guaranteed to satisfy: 0 <= uConnection < HTTP_CORE_MAX_CONNECTIONS
00059  * @param resource The resource part of the URL, as specified by the browser in the request, including any query string (and hash). 
00060  *                 Note: The resource string exists ONLY during the call to this function. The string pointer should not be copied by this function.
00061  * @return nonzero if request is to be handled by this module. zero if not.
00062  */
00063 int HttpStatic_InitRequest(uint16 uConnection, struct HttpBlob resource);
00064 
00065 /**
00066  * Process a static-content HTTP request
00067  * This function is called after a request was already initialized, and a FlashDB content entry was identified during a call to HttpStatic_InitRequest()
00068  * This function calls HttpResponse_*() to send the content data to the browser.
00069  * @param request Pointer to all data available about the request
00070  * @return nonzero if request was handled. zero if not.
00071  */
00072 void HttpStatic_ProcessRequest(struct HttpRequest* request);
00073 
00074 /// @}
00075 
00076 #endif // HTTP_CORE_ENABLE_STATIC
00077 
00078 #endif // _HTTP_STATIC_H_
00079