blob: 7a68da021b2dfbc5621054bacaa859322e69a079 [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
Alex Deymo39910dc2015-11-09 17:04:30 -080020#ifndef UPDATE_ENGINE_COMMON_HTTP_COMMON_H_
21#define UPDATE_ENGINE_COMMON_HTTP_COMMON_H_
Gilad Arnold9bedeb52011-11-17 16:19:57 -080022
Alex Deymo2447c672014-04-02 21:09:10 -070023namespace chromeos_update_engine {
Gilad Arnold9bedeb52011-11-17 16:19:57 -080024
25// Enumeration type for HTTP response codes.
26enum HttpResponseCode {
Amin Hassanib2689592019-01-13 17:04:28 -080027 kHttpResponseUndefined = 0,
28 kHttpResponseOk = 200,
29 kHttpResponseCreated = 201,
30 kHttpResponseAccepted = 202,
31 kHttpResponseNonAuthInfo = 203,
32 kHttpResponseNoContent = 204,
33 kHttpResponseResetContent = 205,
34 kHttpResponsePartialContent = 206,
35 kHttpResponseMultipleChoices = 300,
36 kHttpResponseMovedPermanently = 301,
37 kHttpResponseFound = 302,
38 kHttpResponseSeeOther = 303,
39 kHttpResponseNotModified = 304,
40 kHttpResponseUseProxy = 305,
41 kHttpResponseTempRedirect = 307,
42 kHttpResponseBadRequest = 400,
43 kHttpResponseUnauth = 401,
44 kHttpResponseForbidden = 403,
45 kHttpResponseNotFound = 404,
46 kHttpResponseRequestTimeout = 408,
47 kHttpResponseReqRangeNotSat = 416,
Gilad Arnold9bedeb52011-11-17 16:19:57 -080048 kHttpResponseInternalServerError = 500,
Amin Hassanib2689592019-01-13 17:04:28 -080049 kHttpResponseNotImplemented = 501,
50 kHttpResponseServiceUnavailable = 503,
Gilad Arnold9bedeb52011-11-17 16:19:57 -080051 kHttpResponseVersionNotSupported = 505,
52};
53
54// Returns a standard HTTP status line string for a given response code.
Amin Hassanib2689592019-01-13 17:04:28 -080055const char* GetHttpResponseDescription(HttpResponseCode code);
Gilad Arnold9bedeb52011-11-17 16:19:57 -080056
57// Converts a string beginning with an HTTP error code into numerical value.
Amin Hassanib2689592019-01-13 17:04:28 -080058HttpResponseCode StringToHttpResponseCode(const char* s);
Gilad Arnold9dd1e7c2012-02-16 12:13:36 -080059
60// Enumeration type for HTTP Content-Type.
61enum HttpContentType {
62 kHttpContentTypeUnspecified = 0,
63 kHttpContentTypeTextXml,
64};
65
66// Returns a standard HTTP Content-Type string.
Amin Hassanib2689592019-01-13 17:04:28 -080067const char* GetHttpContentTypeString(HttpContentType type);
Gilad Arnold9dd1e7c2012-02-16 12:13:36 -080068
Alex Deymo2447c672014-04-02 21:09:10 -070069} // namespace chromeos_update_engine
70
Alex Deymo39910dc2015-11-09 17:04:30 -080071#endif // UPDATE_ENGINE_COMMON_HTTP_COMMON_H_