]> err.no Git - sope/blob - sope-appserver/NGObjWeb/NGHttp/NGHttpResponse.h
added svn:keywords and svn:ignore where appropriate. removed CVS artifacts.
[sope] / sope-appserver / NGObjWeb / NGHttp / NGHttpResponse.h
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
6   OGo is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #ifndef __NGHttp_NGHttpResponse_H__
24 #define __NGHttp_NGHttpResponse_H__
25
26 #import "NGHttpMessage.h"
27
28 @class NSString;
29 @class NGHttpRequest, NGHttpChallenge;
30
31 typedef enum {
32   NGHttpStatusCode_unknown = 0,
33
34   // 1xx informational
35   NGHttpStatusCode_Continue                    = 100,
36   NGHttpStatusCode_SwitchingProtocols          = 101,
37
38   // 2xx successful
39   NGHttpStatusCode_OK                          = 200,
40   NGHttpStatusCode_Created                     = 201,
41   NGHttpStatusCode_Accepted                    = 202,
42   NGHttpStatusCode_NonAuthoritativeInformation = 203,
43   NGHttpStatusCode_NoContent                   = 204,
44   NGHttpStatusCode_ResetContent                = 205,
45   NGHttpStatusCode_PartialContent              = 206,
46
47   // 3xx redirection
48   NGHttpStatusCode_MultipleChoices             = 300,
49   NGHttpStatusCode_MovedPermanently            = 301,
50   NGHttpStatusCode_MovedTemporarily            = 302,
51   NGHttpStatusCode_SeeOther                    = 303,
52   NGHttpStatusCode_NotModified                 = 304,
53   NGHttpStatusCode_UseProxy                    = 305,
54
55   // 4xx client error
56   NGHttpStatusCode_BadRequest                  = 400,
57   NGHttpStatusCode_Unauthorized                = 401,
58   NGHttpStatusCode_PaymentRequired             = 402,
59   NGHttpStatusCode_Forbidden                   = 403,
60   NGHttpStatusCode_NotFound                    = 404,
61   NGHttpStatusCode_MethodNotAllowed            = 405,
62   NGHttpStatusCode_NoneAcceptable              = 406,
63   NGHttpStatusCode_ProxyAuthenticationRequired = 407,
64   NGHttpStatusCode_RequestTimeout              = 408,
65   NGHttpStatusCode_Conflict                    = 409,
66   NGHttpStatusCode_Gone                        = 410,
67   NGHttpStatusCode_LengthRequired              = 411,
68   NGHttpStatusCode_UnlessTrue                  = 412,
69
70   // 5xx server error
71   NGHttpStatusCode_InternalServerError         = 500,
72   NGHttpStatusCode_NotImplemented              = 501,
73   NGHttpStatusCode_BadGateway                  = 502,
74   NGHttpStatusCode_ServiceUnavailable          = 503,
75   NGHttpStatusCode_GatewayTimeout              = 504,
76
77   NGHttpStatusCode_last
78 } NGHttpStatusCode;
79
80 @interface NGHttpResponse : NGHttpMessage
81 {
82   NGHttpStatusCode statusCode;
83   NSString         *reason;
84
85   NGHttpRequest *request;
86 }
87
88 - (id)initWithRequest:(NGHttpRequest *)_request;
89
90 - (id)initWithStatus:(int)_status reason:(NSString *)_reason
91   header:(NGHashMap *)_header version:(NSString *)_version;
92
93 // accessors
94
95 - (void)setStatusCode:(NGHttpStatusCode)_code;
96 - (NGHttpStatusCode)statusCode;
97
98 - (void)setReason:(NSString *)_text;
99 - (NSString *)reason;
100
101 - (void)setRequest:(NGHttpRequest *)_request;
102 - (NGHttpRequest *)request;
103
104 @end
105
106 @interface NGHttpResponse(CommonHeaders)
107
108 - (void)setWWWAuthenticate:(NGHttpChallenge *)_challenge;
109 - (NGHttpChallenge *)wwwAuthenticate;
110
111 @end
112
113 static inline BOOL NGIsInformationalHttpStatusCode(NGHttpStatusCode _code) {
114   return ((_code >= 100) && (_code < 200)) ? YES : NO;
115 }
116 static inline BOOL NGIsSuccessfulHttpStatusCode(NGHttpStatusCode _code) {
117   return ((_code >= 200) && (_code < 300)) ? YES : NO;
118 }
119 static inline BOOL NGIsRedirectionHttpStatusCode(NGHttpStatusCode _code) {
120   return ((_code >= 300) && (_code < 400)) ? YES : NO;
121 }
122 static inline BOOL NGIsClientErrorHttpStatusCode(NGHttpStatusCode _code) {
123   return ((_code >= 400) && (_code < 500)) ? YES : NO;
124 }
125 static inline BOOL NGIsServerErrorHttpStatusCode(NGHttpStatusCode _code) {
126   return ((_code >= 500) && (_code < 600)) ? YES : NO;
127 }
128
129 #endif /* __NGHttp_NGHttpResponse_H__ */