1/* 2 * Copyright 2010 Haiku Inc. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Christophe Huriaux, c.huriaux@gmail.com 7 */ 8 9 10#include <UrlResult.h> 11#include <Debug.h> 12 13 14using std::ostream; 15 16 17BUrlResult::BUrlResult(const BUrl& url) 18 : 19 fUrl(url), 20 fRawData(), 21 fHeaders() 22{ 23} 24 25 26BUrlResult::BUrlResult(const BUrlResult& other) 27 : 28 fUrl(), 29 fRawData(), 30 fHeaders() 31{ 32 *this = other; 33} 34 35 36// #pragma mark Result parameters modifications 37 38 39void 40BUrlResult::SetUrl(const BUrl& url) 41{ 42 fUrl = url; 43} 44 45 46// #pragma mark Result parameters access 47 48 49const BUrl& 50BUrlResult::Url() const 51{ 52 return fUrl; 53} 54 55 56const BMallocIO& 57BUrlResult::RawData() const 58{ 59 return fRawData; 60} 61 62 63const BHttpHeaders& 64BUrlResult::Headers() const 65{ 66 return fHeaders; 67} 68 69 70int32 71BUrlResult::StatusCode() const 72{ 73 return fStatusCode; 74} 75 76 77const BString& 78BUrlResult::StatusText() const 79{ 80 return fStatusString; 81} 82 83 84// #pragma mark Result tests 85 86 87bool 88BUrlResult::HasHeaders() const 89{ 90 return (fHeaders.CountHeaders() > 0); 91} 92 93 94// #pragma mark Overloaded operators 95 96 97BUrlResult& 98BUrlResult::operator=(const BUrlResult& other) 99{ 100 fUrl = other.fUrl; 101 fHeaders = other.fHeaders; 102 103 fRawData.SetSize(other.fRawData.BufferLength()); 104 fRawData.WriteAt(0, fRawData.Buffer(), fRawData.BufferLength()); 105 106 return *this; 107} 108 109 110ostream& 111operator<<(ostream& out, const BUrlResult& result) 112{ 113 out.write(reinterpret_cast<const char*>(result.fRawData.Buffer()), 114 result.fRawData.BufferLength()); 115 116 return out; 117} 118