📄 httpd.h
字号:
/**
* \addtogroup httpd
* @{
*/
/**
* \file httpd.h
* \brief Http Web Server Header File.
*/
/*
******************************************************************************
*
Copyright (c) 2006 FameG Shanghai, Inc. All rights reserved.
*
This is unpublished proprietary source code of FameG Shanghai, Inc.
*
The copyright notice above does not evidence any actual or intended
*
publication of such source code.
******************************************************************************
*/
/*
******************************************************************************
*
Project: T4 Hardware TCP/IP
*
Filename: httpd.h
*
Date: 03/27/2006
*
Purpose: http web server header file
*
Author:
******************************************************************************
*/
#ifndef __HTTPD_H__
#define __HTTPD_H__
#include "kernel/system.h"
/*****************************************************************************
* CONSTANT DEFINES *
*****************************************************************************/
#define HTTP_SERVER_PORT 80 /**< Http server well-known port number */
/// @cond DOXYGEN_SKIP
/* HTTP Method */
#define METHOD_ERR 0 /**< Error Method. */
#define METHOD_GET 1 /**< GET Method. */
#define METHOD_HEAD 2 /**< HEAD Method. */
#define METHOD_POST 3 /**< POST Method. */
/* HTTP GET Method */
#define PTYPE_ERR 0 /**< Error file. */
#define PTYPE_HTML 1 /**< HTML file. */
#define PTYPE_GIF 2 /**< GIF file. */
#define PTYPE_TEXT 3 /**< TEXT file. */
#define PTYPE_JPEG 4 /**< JPEG file. */
#define PTYPE_FLASH 5 /**< FLASH file. */
#define PTYPE_MPEG 6 /**< MPEG file. */
#define PTYPE_PDF 7 /**< PDF file. */
#define PTYPE_JAVA 8 /**< JAVA applet file. */
#define PTYPE_CGI 9 /**< CGI */
#define PTYPE_XML 10 /**< XML file */
/* HTTP content param encryption type */
#define TEXT_PLAIN 1
#define FORM_DATA 2
#define ERROR_HTML_PAGE "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: 78\r\n\r\n<HTML>\r\n<BODY>\r\nSorry, the page you requested was not found.\r\n</BODY>\r\n</HTML>\r\n\0"
#define ERROR_REQUEST_PAGE "HTTP/1.1 400 OK\r\nContent-Type: text/html\r\nContent-Length: 50\r\n\r\n<HTML>\r\n<BODY>\r\nInvalid request.\r\n</BODY>\r\n</HTML>\r\n\0"
#define RETURN_CGI_PAGE "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: 59\r\n\r\n<HTML>\r\n<BODY>\r\nCGI command is completed.\r\n</BODY>\r\n</HTML>\r\n\0"
#define HTML_HEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length: "
#define TEXT_HEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\nContent-Length: "
#define GIF_HEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/gif\r\nContent-Length: "
#define JPEG_HEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/jpeg\r\nContent-Length: "
#define FLASH_HEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/x-shockwave-flash\r\nContent-Length: "
#define MPEG_HEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: video/mpeg\r\nContent-Length: "
#define PDF_HEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/pdf\r\nContent-Length: "
#define JAVA_HEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: application/java\r\nContent-Length: "
#define XML_HEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/xml\r\nContent-Length: "
#define MAX_URI_SIZE 50//(RX_BUF_LEN/2 - sizeof(INT8)*2)
#define MAX_CONTENT_SIZE 5000
/// @endcond
/*****************************************************************************
* MACROS *
*****************************************************************************/
/*****************************************************************************
* DATA TYPES *
*****************************************************************************/
/** Structure of HTTP REQUEST */
struct http_request_t
{
UINT8 METHOD; /**< request method. */
UINT8 TYPE; /**< request type. */
UINT8 URI[MAX_URI_SIZE]; /**< request file name. */
UINT8 user_agent[100];
UINT8 boundary[50];
UINT32 content_length;
UINT8 XDATA *content_ptr;
};
/*****************************************************************************
* FUNCTIONS DECLARATION *
*****************************************************************************/
extern void http_parse_request(struct http_request_t *, UINT8 *); /* parse request from peer */
extern void http_find_uri_type(UINT8 * type, char * buf); /* find MIME type of a file */
extern void http_build_response_head(char * buf, UINT8 type, UINT32 len); /* make response header */
extern char* http_get_uri_name(char* uri);
extern char * get_http_param_value(UINT8 * uri, char* param_name, UINT8 enctype, UINT8 paramtype);
/*****************************************************************************
* GLOBAL VARIABLES DECLARATION *
*****************************************************************************/
#endif /*__HTTPD_H__ */
/** @} */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -