blob: f3fe63f31fe630e0131f0675688bad0d262d8030 [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
2// Copyright (C) 2009 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
Gilad Arnold9bedeb52011-11-17 16:19:57 -080016
17// This file contains general definitions used in implementing, testing and
18// emulating communication over HTTP.
19
Gilad Arnoldcf175a02014-07-10 16:48:47 -070020#ifndef UPDATE_ENGINE_HTTP_COMMON_H_
21#define UPDATE_ENGINE_HTTP_COMMON_H_
Gilad Arnold9bedeb52011-11-17 16:19:57 -080022
Alex Deymo2447c672014-04-02 21:09:10 -070023#include <cstdlib>
24
25namespace chromeos_update_engine {
Gilad Arnold9bedeb52011-11-17 16:19:57 -080026
27// Enumeration type for HTTP response codes.
28enum HttpResponseCode {
29 kHttpResponseUndefined = 0,
30 kHttpResponseOk = 200,
31 kHttpResponseCreated = 201,
32 kHttpResponseAccepted = 202,
33 kHttpResponseNonAuthInfo = 203,
34 kHttpResponseNoContent = 204,
35 kHttpResponseResetContent = 205,
36 kHttpResponsePartialContent = 206,
37 kHttpResponseMultipleChoices = 300,
38 kHttpResponseMovedPermanently = 301,
39 kHttpResponseFound = 302,
40 kHttpResponseSeeOther = 303,
41 kHttpResponseNotModified = 304,
42 kHttpResponseUseProxy = 305,
43 kHttpResponseTempRedirect = 307,
44 kHttpResponseBadRequest = 400,
45 kHttpResponseUnauth = 401,
46 kHttpResponseForbidden = 403,
47 kHttpResponseNotFound = 404,
48 kHttpResponseRequestTimeout = 408,
Gilad Arnolde4ad2502011-12-29 17:08:54 -080049 kHttpResponseReqRangeNotSat = 416,
Gilad Arnold9bedeb52011-11-17 16:19:57 -080050 kHttpResponseInternalServerError = 500,
51 kHttpResponseNotImplemented = 501,
52 kHttpResponseServiceUnavailable = 503,
53 kHttpResponseVersionNotSupported = 505,
54};
55
56// Returns a standard HTTP status line string for a given response code.
57const char *GetHttpResponseDescription(HttpResponseCode code);
58
59// Converts a string beginning with an HTTP error code into numerical value.
60HttpResponseCode StringToHttpResponseCode(const char *s);
61
Gilad Arnold9dd1e7c2012-02-16 12:13:36 -080062
63// Enumeration type for HTTP Content-Type.
64enum HttpContentType {
65 kHttpContentTypeUnspecified = 0,
66 kHttpContentTypeTextXml,
67};
68
69// Returns a standard HTTP Content-Type string.
70const char *GetHttpContentTypeString(HttpContentType type);
71
Alex Deymo2447c672014-04-02 21:09:10 -070072} // namespace chromeos_update_engine
73
Gilad Arnoldcf175a02014-07-10 16:48:47 -070074#endif // UPDATE_ENGINE_HTTP_COMMON_H_