Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
http/server/HttpStatic.h@0:50cedd586816, 2015-06-24 (annotated)
- Committer:
- dflet
- Date:
- Wed Jun 24 09:54:16 2015 +0000
- Revision:
- 0:50cedd586816
First commit work in progress
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| dflet | 0:50cedd586816 | 1 | //***************************************************************************** |
| dflet | 0:50cedd586816 | 2 | // Copyright (C) 2014 Texas Instruments Incorporated |
| dflet | 0:50cedd586816 | 3 | // |
| dflet | 0:50cedd586816 | 4 | // All rights reserved. Property of Texas Instruments Incorporated. |
| dflet | 0:50cedd586816 | 5 | // Restricted rights to use, duplicate or disclose this code are |
| dflet | 0:50cedd586816 | 6 | // granted through contract. |
| dflet | 0:50cedd586816 | 7 | // The program may not be used without the written permission of |
| dflet | 0:50cedd586816 | 8 | // Texas Instruments Incorporated or against the terms and conditions |
| dflet | 0:50cedd586816 | 9 | // stipulated in the agreement under which this program has been supplied, |
| dflet | 0:50cedd586816 | 10 | // and under no circumstances can it be used with non-TI connectivity device. |
| dflet | 0:50cedd586816 | 11 | // |
| dflet | 0:50cedd586816 | 12 | //***************************************************************************** |
| dflet | 0:50cedd586816 | 13 | |
| dflet | 0:50cedd586816 | 14 | #ifndef _HTTP_STATIC_H_ |
| dflet | 0:50cedd586816 | 15 | #define _HTTP_STATIC_H_ |
| dflet | 0:50cedd586816 | 16 | |
| dflet | 0:50cedd586816 | 17 | #include "HttpConfig.h" |
| dflet | 0:50cedd586816 | 18 | |
| dflet | 0:50cedd586816 | 19 | #ifdef HTTP_CORE_ENABLE_STATIC |
| dflet | 0:50cedd586816 | 20 | |
| dflet | 0:50cedd586816 | 21 | /** |
| dflet | 0:50cedd586816 | 22 | * @defgroup HttpStatic Static request handler module |
| dflet | 0:50cedd586816 | 23 | * This module implements static content processing for HTTP requests. |
| dflet | 0:50cedd586816 | 24 | * All requests are handled by looking up the URL's resource in the flash database, and returning the content in the response. |
| dflet | 0:50cedd586816 | 25 | * Note this module is only compiled if HTTP_CORE_ENABLE_STATIC is defined in HttpConfig.h |
| dflet | 0:50cedd586816 | 26 | * |
| dflet | 0:50cedd586816 | 27 | * @{ |
| dflet | 0:50cedd586816 | 28 | */ |
| dflet | 0:50cedd586816 | 29 | |
| dflet | 0:50cedd586816 | 30 | #include "HttpRequest.h" |
| dflet | 0:50cedd586816 | 31 | |
| dflet | 0:50cedd586816 | 32 | #ifdef __cplusplus |
| dflet | 0:50cedd586816 | 33 | extern "C" { |
| dflet | 0:50cedd586816 | 34 | #endif |
| dflet | 0:50cedd586816 | 35 | |
| dflet | 0:50cedd586816 | 36 | /** |
| dflet | 0:50cedd586816 | 37 | * Initialize HttpStatic module state for a new request, and identify the request |
| dflet | 0:50cedd586816 | 38 | * This function examines the specified resource string, and looks it up in the Flash Database. |
| dflet | 0:50cedd586816 | 39 | * If found, it commits to process this request by returning nonzero. Otherwise it returns zero. |
| dflet | 0:50cedd586816 | 40 | * @param uConnection The number of the connection. This value is guaranteed to satisfy: 0 <= uConnection < HTTP_CORE_MAX_CONNECTIONS |
| dflet | 0:50cedd586816 | 41 | * @param resource The resource part of the URL, as specified by the browser in the request, including any query string (and hash). |
| dflet | 0:50cedd586816 | 42 | * Note: The resource string exists ONLY during the call to this function. The string pointer should not be copied by this function. |
| dflet | 0:50cedd586816 | 43 | * @return nonzero if request is to be handled by this module. zero if not. |
| dflet | 0:50cedd586816 | 44 | */ |
| dflet | 0:50cedd586816 | 45 | int HttpStatic_InitRequest(UINT16 uConnection, struct HttpBlob resource); |
| dflet | 0:50cedd586816 | 46 | |
| dflet | 0:50cedd586816 | 47 | /** |
| dflet | 0:50cedd586816 | 48 | * Process a static-content HTTP request |
| dflet | 0:50cedd586816 | 49 | * This function is called after a request was already initialized, and a Flash content entry was identified during a call to HttpStatic_InitRequest() |
| dflet | 0:50cedd586816 | 50 | * This function calls HttpResponse_*() to send the content data to the browser. |
| dflet | 0:50cedd586816 | 51 | * @param request Pointer to all data available about the request |
| dflet | 0:50cedd586816 | 52 | * @return nonzero if request was handled. zero if not. |
| dflet | 0:50cedd586816 | 53 | */ |
| dflet | 0:50cedd586816 | 54 | int HttpStatic_ProcessRequest(struct HttpRequest* request); |
| dflet | 0:50cedd586816 | 55 | |
| dflet | 0:50cedd586816 | 56 | /// @} |
| dflet | 0:50cedd586816 | 57 | |
| dflet | 0:50cedd586816 | 58 | #ifdef __cplusplus |
| dflet | 0:50cedd586816 | 59 | } |
| dflet | 0:50cedd586816 | 60 | #endif /* __cplusplus */ |
| dflet | 0:50cedd586816 | 61 | |
| dflet | 0:50cedd586816 | 62 | #endif // HTTP_CORE_ENABLE_STATIC |
| dflet | 0:50cedd586816 | 63 | |
| dflet | 0:50cedd586816 | 64 | #endif // _HTTP_STATIC_H_ |
| dflet | 0:50cedd586816 | 65 |