| Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 1 | // | 
 | 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 Arnold | 9bedeb5 | 2011-11-17 16:19:57 -0800 | [diff] [blame] | 16 |  | 
 | 17 | // This file contains general definitions used in implementing, testing and | 
 | 18 | // emulating communication over HTTP. | 
 | 19 |  | 
| Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 20 | #ifndef UPDATE_ENGINE_COMMON_HTTP_COMMON_H_ | 
 | 21 | #define UPDATE_ENGINE_COMMON_HTTP_COMMON_H_ | 
| Gilad Arnold | 9bedeb5 | 2011-11-17 16:19:57 -0800 | [diff] [blame] | 22 |  | 
| Alex Deymo | 2447c67 | 2014-04-02 21:09:10 -0700 | [diff] [blame] | 23 | namespace chromeos_update_engine { | 
| Gilad Arnold | 9bedeb5 | 2011-11-17 16:19:57 -0800 | [diff] [blame] | 24 |  | 
 | 25 | // Enumeration type for HTTP response codes. | 
 | 26 | enum HttpResponseCode { | 
 | 27 |   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, | 
| Gilad Arnold | e4ad250 | 2011-12-29 17:08:54 -0800 | [diff] [blame] | 47 |   kHttpResponseReqRangeNotSat      = 416, | 
| Gilad Arnold | 9bedeb5 | 2011-11-17 16:19:57 -0800 | [diff] [blame] | 48 |   kHttpResponseInternalServerError = 500, | 
 | 49 |   kHttpResponseNotImplemented      = 501, | 
 | 50 |   kHttpResponseServiceUnavailable  = 503, | 
 | 51 |   kHttpResponseVersionNotSupported = 505, | 
 | 52 | }; | 
 | 53 |  | 
 | 54 | // Returns a standard HTTP status line string for a given response code. | 
 | 55 | const char *GetHttpResponseDescription(HttpResponseCode code); | 
 | 56 |  | 
 | 57 | // Converts a string beginning with an HTTP error code into numerical value. | 
 | 58 | HttpResponseCode StringToHttpResponseCode(const char *s); | 
 | 59 |  | 
| Gilad Arnold | 9dd1e7c | 2012-02-16 12:13:36 -0800 | [diff] [blame] | 60 |  | 
 | 61 | // Enumeration type for HTTP Content-Type. | 
 | 62 | enum HttpContentType { | 
 | 63 |   kHttpContentTypeUnspecified = 0, | 
 | 64 |   kHttpContentTypeTextXml, | 
 | 65 | }; | 
 | 66 |  | 
 | 67 | // Returns a standard HTTP Content-Type string. | 
 | 68 | const char *GetHttpContentTypeString(HttpContentType type); | 
 | 69 |  | 
| Alex Deymo | 2447c67 | 2014-04-02 21:09:10 -0700 | [diff] [blame] | 70 | }  // namespace chromeos_update_engine | 
 | 71 |  | 
| Alex Deymo | 39910dc | 2015-11-09 17:04:30 -0800 | [diff] [blame] | 72 | #endif  // UPDATE_ENGINE_COMMON_HTTP_COMMON_H_ |