1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
/* --------------------------------------------------------------------------
MusicBrainz -- The Internet music metadatabase
Copyright (C) 2000 Emusic.com
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
$Id: http.h,v 1.3 2000/09/22 14:15:01 robert Exp $
----------------------------------------------------------------------------*/
#ifndef __HTTP_H__
#define __HTTP_H__
#include "types.h"
#include "errors.h"
#include <string>
using namespace std;
class MBHttp
{
public:
MBHttp(void);
virtual ~MBHttp(void);
Error DownloadToFile(const string &url,
const string &xml,
const string &destPath);
Error DownloadToString(const string &url,
const string &xml,
string &page);
virtual void Progress(unsigned int bytesReceived, unsigned int maxBytes);
void SetProxyURL(const string &proxy);
private:
Error Download(const string &url, const string &xml, bool fileDownload);
int WriteToFile(unsigned char *buffer, unsigned int size);
int WriteToBuffer(unsigned char *buffer, unsigned int size);
int32 GetContentLengthFromHeader(const char* buffer);
bool IsHTTPHeaderComplete(char* buffer, uint32 length);
Error Connect(int hHandle, const struct sockaddr *pAddr, int &iRet);
Error Recv(int hHandle, char *pBuffer, int iSize,
int iFlags, int &iRead);
Error Send(int hHandle, char *pBuffer, int iSize,
int iFlags, int &iSend);
bool m_exit;
unsigned char *m_buffer;
uint32 m_bufferSize, m_bytesInBuffer;
FILE *m_file;
string m_destPath, m_proxy;
};
#endif
|