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 | |
| 8 | #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_HTTP_COMMON_H__ |
| 9 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_HTTP_COMMON_H__ |
| 10 | |
| 11 | #include <stdlib.h> |
| 12 | |
| 13 | // Enumeration type for HTTP response codes. |
| 14 | enum HttpResponseCode { |
| 15 | kHttpResponseUndefined = 0, |
| 16 | kHttpResponseOk = 200, |
| 17 | kHttpResponseCreated = 201, |
| 18 | kHttpResponseAccepted = 202, |
| 19 | kHttpResponseNonAuthInfo = 203, |
| 20 | kHttpResponseNoContent = 204, |
| 21 | kHttpResponseResetContent = 205, |
| 22 | kHttpResponsePartialContent = 206, |
| 23 | kHttpResponseMultipleChoices = 300, |
| 24 | kHttpResponseMovedPermanently = 301, |
| 25 | kHttpResponseFound = 302, |
| 26 | kHttpResponseSeeOther = 303, |
| 27 | kHttpResponseNotModified = 304, |
| 28 | kHttpResponseUseProxy = 305, |
| 29 | kHttpResponseTempRedirect = 307, |
| 30 | kHttpResponseBadRequest = 400, |
| 31 | kHttpResponseUnauth = 401, |
| 32 | kHttpResponseForbidden = 403, |
| 33 | kHttpResponseNotFound = 404, |
| 34 | kHttpResponseRequestTimeout = 408, |
Gilad Arnold | e4ad250 | 2011-12-29 17:08:54 -0800 | [diff] [blame] | 35 | kHttpResponseReqRangeNotSat = 416, |
Gilad Arnold | 9bedeb5 | 2011-11-17 16:19:57 -0800 | [diff] [blame] | 36 | kHttpResponseInternalServerError = 500, |
| 37 | kHttpResponseNotImplemented = 501, |
| 38 | kHttpResponseServiceUnavailable = 503, |
| 39 | kHttpResponseVersionNotSupported = 505, |
| 40 | }; |
| 41 | |
| 42 | // Returns a standard HTTP status line string for a given response code. |
| 43 | const char *GetHttpResponseDescription(HttpResponseCode code); |
| 44 | |
| 45 | // Converts a string beginning with an HTTP error code into numerical value. |
| 46 | HttpResponseCode StringToHttpResponseCode(const char *s); |
| 47 | |
Gilad Arnold | 9dd1e7c | 2012-02-16 12:13:36 -0800 | [diff] [blame] | 48 | |
| 49 | // Enumeration type for HTTP Content-Type. |
| 50 | enum HttpContentType { |
| 51 | kHttpContentTypeUnspecified = 0, |
| 52 | kHttpContentTypeTextXml, |
| 53 | }; |
| 54 | |
| 55 | // Returns a standard HTTP Content-Type string. |
| 56 | const char *GetHttpContentTypeString(HttpContentType type); |
| 57 | |
Gilad Arnold | 9bedeb5 | 2011-11-17 16:19:57 -0800 | [diff] [blame] | 58 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_HTTP_COMMON_H__ |