blob: b2ffbc7805ba14cf4d3fe6b82e19ec936ae28408 [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
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.
14enum 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 Arnolde4ad2502011-12-29 17:08:54 -080035 kHttpResponseReqRangeNotSat = 416,
Gilad Arnold9bedeb52011-11-17 16:19:57 -080036 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.
43const char *GetHttpResponseDescription(HttpResponseCode code);
44
45// Converts a string beginning with an HTTP error code into numerical value.
46HttpResponseCode StringToHttpResponseCode(const char *s);
47
Gilad Arnold9dd1e7c2012-02-16 12:13:36 -080048
49// Enumeration type for HTTP Content-Type.
50enum HttpContentType {
51 kHttpContentTypeUnspecified = 0,
52 kHttpContentTypeTextXml,
53};
54
55// Returns a standard HTTP Content-Type string.
56const char *GetHttpContentTypeString(HttpContentType type);
57
Gilad Arnold9bedeb52011-11-17 16:19:57 -080058#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_HTTP_COMMON_H__