Port of TI's CC3100 Websock camera demo. Using FreeRTOS, mbedTLS, also parts of Arducam for cams ov5642 and 0v2640. Can also use MT9D111. Work in progress. Be warned some parts maybe a bit flacky. This is for Seeed Arch max only, for an M3, see the demo for CM3 using the 0v5642 aducam mini.
HttpResponse.h
00001 //***************************************************************************** 00002 // Copyright (C) 2014 Texas Instruments Incorporated 00003 // 00004 // All rights reserved. Property of Texas Instruments Incorporated. 00005 // Restricted rights to use, duplicate or disclose this code are 00006 // granted through contract. 00007 // The program may not be used without the written permission of 00008 // Texas Instruments Incorporated or against the terms and conditions 00009 // stipulated in the agreement under which this program has been supplied, 00010 // and under no circumstances can it be used with non-TI connectivity device. 00011 // 00012 //***************************************************************************** 00013 00014 #ifndef _HTTP_RESPONSE_H_ 00015 #define _HTTP_RESPONSE_H_ 00016 00017 #include "datatypes.h" 00018 #include "HttpString.h" 00019 00020 /** 00021 * @defgroup HttpResponse HTTP and WebSocket Response modules 00022 * This module implements routines to allow content handler modules to build and send HTTP responses back to the client. 00023 * There are two layers in this module: 00024 * - The lower layer consists of HttpResponse_Headers() and HttpResponse_Content(). These routines allow the caller to specify all details of the response. 00025 * - The higher layer consists of HttpResponse_Canned*(). These routines emit canned (pre-made) responses, such as redirects and errors, which are useful in many situations. 00026 * 00027 * @{ 00028 */ 00029 00030 #define HTTP_STATUS_OK 200 00031 #define HTTP_STATUS_REDIRECT_PERMANENT 301 00032 #define HTTP_STATUS_REDIRECT_TEMPORARY 302 00033 #define HTTP_STATUS_ERROR_UNAUTHORIZED 401 00034 #define HTTP_STATUS_ERROR_NOT_FOUND 404 00035 #define HTTP_STATUS_ERROR_NOT_ACCEPTED 406 00036 #define HTTP_STATUS_ERROR_INTERNAL 500 00037 00038 00039 /// The response data is gzip-compressed. Implies the header Content-Encoding: gzip 00040 #define HTTP_RESPONSE_FLAG_COMPRESSED (1 << 0) 00041 00042 #define WS_STATUS_OK 1000 // Purpose of connection has been fulfilled 00043 #define WS_STATUS_GOING_AWAY 1001 //Server going going down or browser re-navigating 00044 #define WS_STATUS_ERROR_PROTOCOL 1002 //Protocol error 00045 #define WS_STATUS_ERROR_DATATYPE 1003 //Text frame or binary sent not supported by the application 00046 #define WS_STATUS_ERROR_ENCODING 1007 //Type not consistent with the rest of the message 00047 #define WS_STATUS_ERROR_POLICY 1008 //Policy violation for server 00048 #define WS_STATUS_ERROR_OVERFLOW 1009 //Data too large for buffer 00049 #define WS_STATUS_ERROR_UNEXPECTED 1011 //Unexpected event 00050 00051 #ifdef __cplusplus 00052 extern "C" { 00053 #endif 00054 00055 00056 /** 00057 * Respond with the specified HTTP status and headers 00058 * @param uConnection The connection number, as it appears in the HttpRequest structure 00059 * @param uHttpStatus The HTTP status number to response with. Must be one of HTTP_STATUS_* 00060 * @param uFlags Flags which are manifested in the response headers. See HTTP_RESPONSE_FLAG_* 00061 * @param uContentLength The total length of content which will be sent via HttpResponse_Content() 00062 * @param contentType The content type string, or NULL to omit the content type 00063 * @param location A string which will be used for the Location header, or NULL to omit the Location header 00064 */ 00065 int HttpResponse_Headers(UINT16 uConnection, UINT16 uHttpStatus, UINT16 uFlags, UINT32 uContentLength, struct HttpBlob contentType, struct HttpBlob location); 00066 00067 /** 00068 * Retrieves the pointer and size of the packet-send buffer 00069 * This function should be called by content handlers that wish to use the already-allocated packet-send buffer in calls to HttpResponse_Content() 00070 * @param[out] pPacketSendBuffer Returns the pointer and size of the packet-send buffer 00071 */ 00072 void HttpResponse_GetPacketSendBuffer(struct HttpBlob* pPacketSendBuffer); 00073 00074 /** 00075 * Send response content to the client. 00076 * This function may be called more than once, until all the content is sent. 00077 * @param uConnection The connection number, as it appears in the HttpRequest structure 00078 * @param content Content blob to send to the client. 00079 */ 00080 int HttpResponse_Content(UINT16 uConnection, struct HttpBlob content); 00081 00082 /** 00083 * Sends a canned response, with an HTTP redirect 00084 * This function should be called *instead* of HttpResponse_Status(), HttpResponse_Headers() and HttpResponse_Content() 00085 * @param uConnection The connection number, as it appears in the HttpRequest structure 00086 * @param pLocation The redirect URL 00087 * @param bPermanent zero for temporary redirect, nonzero for permanent redirect 00088 */ 00089 int HttpResponse_CannedRedirect(UINT16 uConnection, struct HttpBlob location, UINT16 bPermanent); 00090 00091 /** 00092 * Sends a canned response, with an error message 00093 * This function should be called *instead* of HttpResponse_Status(), HttpResponse_Headers() and HttpResponse_Content() 00094 * @param uConnection The connection number, as it appears in the HttpRequest structure 00095 * @param uHttpStatus The HTTP error status. Must be one of HTTP_STATUS_ERROR_* 00096 */ 00097 int HttpResponse_CannedError(UINT16 uConnection, UINT16 uHttpStatus); 00098 00099 /// @} 00100 #ifdef __cplusplus 00101 } 00102 #endif /* __cplusplus */ 00103 #endif //_HTTP_RESPONSE_H_ 00104
Generated on Tue Jul 12 2022 22:22:38 by 1.7.2