1 /*
2 * FreeRTOS V202212.00
3 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * https://www.FreeRTOS.org
23 * https://github.com/FreeRTOS
24 *
25 */
26
27 /**
28 *!
29 *! The protocols implemented in this file are intended to be demo quality only,
30 *! and not for production devices.
31 *!
32 */
33
34 /* Standard includes. */
35 #include <stdio.h>
36 #include <stdlib.h>
37
38 /* FreeRTOS includes. */
39 #include "FreeRTOS.h"
40
41 #include "FreeRTOS_HTTP_commands.h"
42
43 const struct xWEB_COMMAND xWebCommands[ WEB_CMD_COUNT ] =
44 {
45 { 3, "GET", ECMD_GET },
46 { 4, "HEAD", ECMD_HEAD },
47 { 4, "POST", ECMD_POST },
48 { 3, "PUT", ECMD_PUT },
49 { 6, "DELETE", ECMD_DELETE },
50 { 5, "TRACE", ECMD_TRACE },
51 { 7, "OPTIONS", ECMD_OPTIONS },
52 { 7, "CONNECT", ECMD_CONNECT },
53 { 5, "PATCH", ECMD_PATCH },
54 { 4, "UNKN", ECMD_UNK },
55 };
56
webCodename(int aCode)57 const char * webCodename( int aCode )
58 {
59 switch( aCode )
60 {
61 case WEB_REPLY_OK: /* = 200, */
62 return "OK";
63
64 case WEB_NO_CONTENT: /* 204 */
65 return "No content";
66
67 case WEB_BAD_REQUEST: /* = 400, */
68 return "Bad request";
69
70 case WEB_UNAUTHORIZED: /* = 401, */
71 return "Authorization Required";
72
73 case WEB_NOT_FOUND: /* = 404, */
74 return "Not Found";
75
76 case WEB_GONE: /* = 410, */
77 return "Done";
78
79 case WEB_PRECONDITION_FAILED: /* = 412, */
80 return "Precondition Failed";
81
82 case WEB_INTERNAL_SERVER_ERROR: /* = 500, */
83 return "Internal Server Error";
84 }
85
86 return "Unknown";
87 }
88