summaryrefslogtreecommitdiff
path: root/libs/networking/src/HTTPStatus.cc
blob: 659294dafcd9479c8dd5a4541e8db0b28bb413dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/**
 * ======================== legal notice ======================
 * 
 * File:      HTTPStatus.cc
 * Created:   3. Juli 2012, 17
 * Author:    <a href="mailto:geronimo013@gmx.de">Geronimo</a>
 * Project:   libnetworking: classes for tcp/ip sockets and http-protocol handling
 * 
 * CMP - compound media player
 * 
 * is a client/server mediaplayer intended to play any media from any workstation
 * without the need to export or mount shares. cmps is an easy to use backend
 * with a (ready to use) HTML-interface. Additionally the backend supports
 * authentication via HTTP-digest authorization.
 * cmpc is a client with vdr-like osd-menues.
 * 
 * Copyright (c) 2012 Reinhard Mantey, some rights reserved!
 * published under Creative Commons by-sa
 * For details see http://creativecommons.org/licenses/by-sa/3.0/
 * 
 * The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
 * 
 * --------------------------------------------------------------
 */
#include <HTTPStatus.h>
#include <stdlib.h>

const char *httpStatus2Text(int Status)
{
  switch (Status) {
    case HTTP_Continue: return "Continue";
    case HTTP_SwitchProtocol: return "Gonna switch Protocol";
    case HTTP_OK: return "Ok";
    case HTTP_Created: return "Created";
    case HTTP_Accepted: return "Accepted";
    case HTTP_NoContent: return "No Content";
    case HTTP_ResetContent: return "reset Content";
    case HTTP_PartialContent: return "partial Content";
    case HTTP_MultipleChoices: return "Multiple Choices";
    case HTTP_MovedPermanently: return "Permanently moved";
    case HTTP_Found: return "Found";
    case HTTP_SeeOther: return "See other";
    case HTTP_NotModified: return "Not modified";
    case HTTP_UseProxy: return "Use Proxy";
    case HTTP_MovedTemporarily: return "Temporarily moved";
    case HTTP_BadRequest: return "Bad Request";
    case HTTP_UnAuthorized: return "Unauthorized";
    case HTTP_PaymentRequired: return "Payment required";
    case HTTP_Forbidden: return "Forbidden";
    case HTTP_NotFound: return "Not Found";
    case HTTP_MethodNotAllowed: return "Not Allowed";
    case HTTP_NotAcceptable: return "Not acceptable";
    case HTTP_ProxyAuthenticationRequired: return "Authentication required";
    case HTTP_RequestTimeout: return "Request timed out";
    case HTTP_Conflict: return "Conflict";
    case HTTP_Gone: return "Gone";
    case HTTP_LengthRequired: return "Length required";
    case HTTP_PreconditionFailed: return "Precondition failed";
    case HTTP_RequestTooLarge: return "Request too large";
    case HTTP_RequestURIToLong: return "Requested URI to long";
    case HTTP_UnsupportedMediaType: return "Unsupported Media Type";
    case HTTP_RequestRangeNotSatisfiable: return "Request Range Not satisfiable";
    case HTTP_ExpectationFailed: return "Expectation failed";
    case HTTP_InternalServerError: return "Internal Server Error";
    case HTTP_NotImplemented: return "Not implemented";
    case HTTP_BadGateway: return "Bad Gateway";
    case HTTP_ServiceUnavailable: return "Service unavailable";
    case HTTP_GatewayTimeout: return "Gateway timed out";
    case HTTP_VersionNotSupported: return "Version not supported";
    default: return "Unsupported/Unknown status";
    }
}

HTTPStatusCode strtoHTTPStatus(const char *p)
{
  int tmp = atoi(p);

  switch (tmp) {
    case HTTP_Continue: return HTTP_Continue;
    case HTTP_SwitchProtocol: return HTTP_SwitchProtocol;
    case HTTP_OK: return HTTP_OK;
    case HTTP_Created: return HTTP_Created;
    case HTTP_Accepted: return HTTP_Accepted;
    case HTTP_NoContent: return HTTP_NoContent;
    case HTTP_ResetContent: return HTTP_ResetContent;
    case HTTP_PartialContent: return HTTP_PartialContent;
    case HTTP_MultipleChoices: return HTTP_MultipleChoices;
    case HTTP_MovedPermanently: return HTTP_MovedPermanently;
    case HTTP_Found: return HTTP_Found;
    case HTTP_SeeOther: return HTTP_SeeOther;
    case HTTP_NotModified: return HTTP_NotModified;
    case HTTP_UseProxy: return HTTP_UseProxy;
    case HTTP_MovedTemporarily: return HTTP_MovedTemporarily;
    case HTTP_BadRequest: return HTTP_BadRequest;
    case HTTP_UnAuthorized: return HTTP_UnAuthorized;
    case HTTP_PaymentRequired: return HTTP_PaymentRequired;
    case HTTP_Forbidden: return HTTP_Forbidden;
    case HTTP_NotFound: return HTTP_NotFound;
    case HTTP_MethodNotAllowed: return HTTP_MethodNotAllowed;
    case HTTP_NotAcceptable: return HTTP_NotAcceptable;
    case HTTP_ProxyAuthenticationRequired: return HTTP_ProxyAuthenticationRequired;
    case HTTP_RequestTimeout: return HTTP_RequestTimeout;
    case HTTP_Conflict: return HTTP_Conflict;
    case HTTP_Gone: return HTTP_Gone;
    case HTTP_LengthRequired: return HTTP_LengthRequired;
    case HTTP_PreconditionFailed: return HTTP_PreconditionFailed;
    case HTTP_RequestTooLarge: return HTTP_RequestTooLarge;
    case HTTP_RequestURIToLong: return HTTP_RequestURIToLong;
    case HTTP_UnsupportedMediaType: return HTTP_UnsupportedMediaType;
    case HTTP_RequestRangeNotSatisfiable: return HTTP_RequestRangeNotSatisfiable;
    case HTTP_ExpectationFailed: return HTTP_ExpectationFailed;
    case HTTP_InternalServerError: return HTTP_InternalServerError;
    case HTTP_NotImplemented: return HTTP_NotImplemented;
    case HTTP_BadGateway: return HTTP_BadGateway;
    case HTTP_ServiceUnavailable: return HTTP_ServiceUnavailable;
    case HTTP_GatewayTimeout: return HTTP_GatewayTimeout;
    case HTTP_VersionNotSupported: return HTTP_VersionNotSupported;
    default: return HTTP_InternalServerError;
    }
}