1 module hunt.http.client.HttpClientResponse;
2 
3 import hunt.http.Cookie;
4 import hunt.http.HttpHeader;
5 import hunt.http.HttpFields;
6 import hunt.http.HttpVersion;
7 import hunt.http.HttpRequest;
8 import hunt.http.HttpResponse;
9 import hunt.http.HttpStatus;
10 
11 
12 import hunt.io.ByteBuffer;
13 import hunt.io.BufferUtils;
14 import hunt.Exceptions;
15 
16 import std.algorithm;
17 import std.array;
18 
19 alias Response = HttpClientResponse;
20 
21 /**
22  * 
23  */
24 class HttpClientResponse : HttpResponse {
25 
26 	private Cookie[] _cookies;
27 	
28 	this(HttpVersion ver, int status, string reason) {
29 		this(ver, status, reason, new HttpFields(), long.min);
30 	}
31 	
32 	this(HttpVersion ver, int status, string reason, HttpFields fields, long contentLength) {
33 		super(ver, status, reason, fields, contentLength);
34 	}
35 
36 
37 	/** Returns true if this response redirects to another resource. */
38 	bool isRedirect() {
39 		switch (_status) {
40 			case HttpStatus.PERMANENT_REDIRECT_308:
41 			case HttpStatus.TEMPORARY_REDIRECT_307:
42 			case HttpStatus.MULTIPLE_CHOICES_300:
43 			case HttpStatus.MOVED_PERMANENTLY_301:
44 			case HttpStatus.MOVED_TEMPORARILY_302:
45 			case HttpStatus.SEE_OTHER_303:
46 				return true;
47 				
48 			default:
49 				return false;
50 		}
51 	}
52 	
53 	Cookie[] cookies() {
54         if (_cookies is null) {
55             _cookies = getFields().getValuesList(HttpHeader.SET_COOKIE)
56 					.map!(parseSetCookie).array;
57         }
58 		
59 		return _cookies;
60     }
61 
62 }