tcp: Fix 64 bit build with debugging features enabled.
[haiku.git] / src / kits / network / libnetapi / HttpResult.cpp
blobeccca7b67b23adfd47180b7767647561e717f485
1 /*
2 * Copyright 2010 Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Christophe Huriaux, c.huriaux@gmail.com
7 */
10 #include <HttpResult.h>
11 #include <Debug.h>
14 using std::ostream;
17 BHttpResult::BHttpResult(const BUrl& url)
19 fUrl(url),
20 fHeaders(),
21 fStatusCode(0)
26 BHttpResult::BHttpResult(const BHttpResult& other)
28 fUrl(other.fUrl),
29 fHeaders(other.fHeaders),
30 fStatusCode(other.fStatusCode),
31 fStatusString(other.fStatusString)
36 BHttpResult::~BHttpResult()
41 // #pragma mark Result parameters modifications
44 void
45 BHttpResult::SetUrl(const BUrl& url)
47 fUrl = url;
51 // #pragma mark Result parameters access
54 const BUrl&
55 BHttpResult::Url() const
57 return fUrl;
61 BString
62 BHttpResult::ContentType() const
64 return Headers()["Content-Type"];
68 size_t
69 BHttpResult::Length() const
71 const char* length = Headers()["Content-Length"];
72 if (length == NULL)
73 return 0;
74 return atoi(length);
78 const BHttpHeaders&
79 BHttpResult::Headers() const
81 return fHeaders;
85 int32
86 BHttpResult::StatusCode() const
88 return fStatusCode;
92 const BString&
93 BHttpResult::StatusText() const
95 return fStatusString;
99 // #pragma mark Result tests
102 bool
103 BHttpResult::HasHeaders() const
105 return fHeaders.CountHeaders() > 0;
109 // #pragma mark Overloaded members
112 BHttpResult&
113 BHttpResult::operator=(const BHttpResult& other)
115 if (this == &other)
116 return *this;
118 fUrl = other.fUrl;
119 fHeaders = other.fHeaders;
120 fStatusCode = other.fStatusCode;
121 fStatusString = other.fStatusString;
123 return *this;