26 #ifndef _COVERARTARCHIVE_HTTP_FETCH_
27 #define _COVERARTARCHIVE_HTTP_FETCH_
32 namespace CoverArtArchive
34 class CHTTPFetchPrivate;
39 CExceptionBase(
const std::string& ErrorMessage,
const std::string& Exception)
40 : m_ErrorMessage(ErrorMessage),
41 m_Exception(Exception)
43 m_FullMessage=m_Exception +
": " + m_ErrorMessage;
48 virtual const char*
what()
const throw()
50 return m_FullMessage.c_str();
54 std::string m_ErrorMessage;
55 std::string m_Exception;
56 std::string m_FullMessage;
154 return m_Location.c_str();
158 std::string m_Location;
261 int Fetch(
const std::string& URL,
bool FollowRedirects=
true);
271 std::vector<unsigned char>
Data()
const;
304 CHTTPFetchPrivate *
const m_d;
306 int DoRequest(
const std::string& URL);
308 static int httpAuth(
void *userdata,
const char *realm,
int attempts,
char *username,
char *password);
309 static int proxyAuth(
void *userdata,
const char *realm,
int attempts,
char *username,
char *password);
310 static int httpResponseReader(
void *userdata,
const char *buf,
size_t len);
Definition: HTTPFetch.h:36
Object for make HTTP requests.
Definition: HTTPFetch.h:167
void SetPassword(const std::string &Password)
Set the password to use.
Exception thrown when an error occurs connecting to web service.
Definition: HTTPFetch.h:63
Exception thrown when the requested resource is not found.
Definition: HTTPFetch.h:128
void SetProxyHost(const std::string &ProxyHost)
Set the proxy server to use.
std::vector< unsigned char > Data() const
Get the data receieved.
void SetProxyPassword(const std::string &ProxyPassword)
Set the proxy password to use.
Exception thrown when an invalid request is made.
Definition: HTTPFetch.h:115
CAuthenticationError(const std::string &ErrorMessage)
Definition: HTTPFetch.h:92
void SetUserName(const std::string &UserName)
Set the user name to use.
int Result() const
libneon result code from the request
void SetProxyPort(int ProxyPort)
Set the proxy port to use.
CResourceNotFoundError(const std::string &ErrorMessage)
Definition: HTTPFetch.h:131
int Status() const
Status.
CFetchError(const std::string &ErrorMessage)
Definition: HTTPFetch.h:105
const char * Location() const
Definition: HTTPFetch.h:152
CRedirect(const std::string &Location)
Definition: HTTPFetch.h:144
Exception thrown when an error occurs fetching data.
Definition: HTTPFetch.h:102
Exception thrown when an authentication error occurs.
Definition: HTTPFetch.h:89
CTimeoutError(const std::string &ErrorMessage)
Definition: HTTPFetch.h:79
Exception thrown when a connection to the web service times out.
Definition: HTTPFetch.h:76
int Fetch(const std::string &URL, bool FollowRedirects=true)
Make a request to the server.
std::string ErrorMessage() const
Return the error message from the request.
virtual const char * what() const
Definition: HTTPFetch.h:48
CRequestError(const std::string &ErrorMessage)
Definition: HTTPFetch.h:118
virtual ~CExceptionBase()
Definition: HTTPFetch.h:46
virtual ~CRedirect()
Definition: HTTPFetch.h:150
CHTTPFetch(const std::string &UserAgent)
Constructor.
Exception thrown when a redirect is returned.
Definition: HTTPFetch.h:141
CExceptionBase(const std::string &ErrorMessage, const std::string &Exception)
Definition: HTTPFetch.h:39
CConnectionError(const std::string &ErrorMessage)
Definition: HTTPFetch.h:66
void SetProxyUserName(const std::string &ProxyUserName)
Set the proxy user name to use.