Gilad Arnold | 9bedeb5 | 2011-11-17 16:19:57 -0800 | [diff] [blame] | 1 | // Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | // This file contains general definitions used in implementing, testing and |
| 6 | // emulating communication over HTTP. |
| 7 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 8 | #ifndef UPDATE_ENGINE_HTTP_COMMON_H_ |
| 9 | #define UPDATE_ENGINE_HTTP_COMMON_H_ |
Gilad Arnold | 9bedeb5 | 2011-11-17 16:19:57 -0800 | [diff] [blame] | 10 | |
Alex Deymo | 2447c67 | 2014-04-02 21:09:10 -0700 | [diff] [blame] | 11 | #include <cstdlib> |
| 12 | |
| 13 | namespace chromeos_update_engine { |
Gilad Arnold | 9bedeb5 | 2011-11-17 16:19:57 -0800 | [diff] [blame] | 14 | |
| 15 | // Enumeration type for HTTP response codes. |
| 16 | enum HttpResponseCode { |
| 17 | kHttpResponseUndefined = 0, |
| 18 | kHttpResponseOk = 200, |
| 19 | kHttpResponseCreated = 201, |
| 20 | kHttpResponseAccepted = 202, |
| 21 | kHttpResponseNonAuthInfo = 203, |
| 22 | kHttpResponseNoContent = 204, |
| 23 | kHttpResponseResetContent = 205, |
| 24 | kHttpResponsePartialContent = 206, |
| 25 | kHttpResponseMultipleChoices = 300, |
| 26 | kHttpResponseMovedPermanently = 301, |
| 27 | kHttpResponseFound = 302, |
| 28 | kHttpResponseSeeOther = 303, |
| 29 | kHttpResponseNotModified = 304, |
| 30 | kHttpResponseUseProxy = 305, |
| 31 | kHttpResponseTempRedirect = 307, |
| 32 | kHttpResponseBadRequest = 400, |
| 33 | kHttpResponseUnauth = 401, |
| 34 | kHttpResponseForbidden = 403, |
| 35 | kHttpResponseNotFound = 404, |
| 36 | kHttpResponseRequestTimeout = 408, |
Gilad Arnold | e4ad250 | 2011-12-29 17:08:54 -0800 | [diff] [blame] | 37 | kHttpResponseReqRangeNotSat = 416, |
Gilad Arnold | 9bedeb5 | 2011-11-17 16:19:57 -0800 | [diff] [blame] | 38 | kHttpResponseInternalServerError = 500, |
| 39 | kHttpResponseNotImplemented = 501, |
| 40 | kHttpResponseServiceUnavailable = 503, |
| 41 | kHttpResponseVersionNotSupported = 505, |
| 42 | }; |
| 43 | |
| 44 | // Returns a standard HTTP status line string for a given response code. |
| 45 | const char *GetHttpResponseDescription(HttpResponseCode code); |
| 46 | |
| 47 | // Converts a string beginning with an HTTP error code into numerical value. |
| 48 | HttpResponseCode StringToHttpResponseCode(const char *s); |
| 49 | |
Gilad Arnold | 9dd1e7c | 2012-02-16 12:13:36 -0800 | [diff] [blame] | 50 | |
| 51 | // Enumeration type for HTTP Content-Type. |
| 52 | enum HttpContentType { |
| 53 | kHttpContentTypeUnspecified = 0, |
| 54 | kHttpContentTypeTextXml, |
| 55 | }; |
| 56 | |
| 57 | // Returns a standard HTTP Content-Type string. |
| 58 | const char *GetHttpContentTypeString(HttpContentType type); |
| 59 | |
Alex Deymo | 2447c67 | 2014-04-02 21:09:10 -0700 | [diff] [blame] | 60 | } // namespace chromeos_update_engine |
| 61 | |
Gilad Arnold | cf175a0 | 2014-07-10 16:48:47 -0700 | [diff] [blame] | 62 | #endif // UPDATE_ENGINE_HTTP_COMMON_H_ |