blob: a4f7bdc4e3a74b28caefc2df51ec8110c1d3a0ee [file] [log] [blame]
Gilad Arnold9bedeb52011-11-17 16:19:57 -08001// 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 Arnoldcf175a02014-07-10 16:48:47 -07008#ifndef UPDATE_ENGINE_HTTP_COMMON_H_
9#define UPDATE_ENGINE_HTTP_COMMON_H_
Gilad Arnold9bedeb52011-11-17 16:19:57 -080010
Alex Deymo2447c672014-04-02 21:09:10 -070011#include <cstdlib>
12
13namespace chromeos_update_engine {
Gilad Arnold9bedeb52011-11-17 16:19:57 -080014
15// Enumeration type for HTTP response codes.
16enum 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 Arnolde4ad2502011-12-29 17:08:54 -080037 kHttpResponseReqRangeNotSat = 416,
Gilad Arnold9bedeb52011-11-17 16:19:57 -080038 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.
45const char *GetHttpResponseDescription(HttpResponseCode code);
46
47// Converts a string beginning with an HTTP error code into numerical value.
48HttpResponseCode StringToHttpResponseCode(const char *s);
49
Gilad Arnold9dd1e7c2012-02-16 12:13:36 -080050
51// Enumeration type for HTTP Content-Type.
52enum HttpContentType {
53 kHttpContentTypeUnspecified = 0,
54 kHttpContentTypeTextXml,
55};
56
57// Returns a standard HTTP Content-Type string.
58const char *GetHttpContentTypeString(HttpContentType type);
59
Alex Deymo2447c672014-04-02 21:09:10 -070060} // namespace chromeos_update_engine
61
Gilad Arnoldcf175a02014-07-10 16:48:47 -070062#endif // UPDATE_ENGINE_HTTP_COMMON_H_