You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
1.9 KiB
C++
82 lines
1.9 KiB
C++
#ifndef _HTTPCLIENT_H
|
|
#define _HTTPCLIENT_H
|
|
|
|
#include "cserver.h"
|
|
#include <stdio.h>
|
|
#include "packet.h"
|
|
#define llmem_alloc malloc
|
|
#define llmem_free free
|
|
#define DebugOutLn //
|
|
#include <llqueue_dequeue.h>
|
|
|
|
typedef enum {
|
|
CONNECT_TO_HTTP,
|
|
CONNECTED,
|
|
CONNECTED_SENDING_HEAD,
|
|
WAIT_200,
|
|
CONNECTED_SENDING_GET,
|
|
WAIT_200b,
|
|
CONNECTED_GET_OPEN,
|
|
WAIT_TRANSFER_FLUSHED,
|
|
} httpstatus;
|
|
|
|
|
|
/************************************************************************/
|
|
/* HTTP OPEN FILE */
|
|
/************************************************************************/
|
|
class CHttpClient {
|
|
public:
|
|
CHttpClient(char *http_server,char *http_user,char *http_pass);
|
|
~CHttpClient();
|
|
|
|
int GetLastError(){
|
|
return m_last_error;
|
|
}
|
|
//int Get(char * file, char * destbuf, int dstbufsize);
|
|
int Get(char * file, FILE * fd);
|
|
|
|
// Funktionen für Partielles Lesen
|
|
int Open(char *filename);
|
|
int Close();
|
|
int ReadHttp(char * buf, int size);
|
|
int List(char * dir, char *listbuf, int listbufsize);
|
|
|
|
int GetFileSize(){
|
|
return m_filesize;
|
|
}
|
|
|
|
protected:
|
|
|
|
int m_last_error;
|
|
fd_set fd;
|
|
httpstatus status;
|
|
CServer Server;
|
|
CServer HttpTransfer;
|
|
CNetPacket m_ServerName;
|
|
|
|
int Read(int handle, char* buf, int bufsize);
|
|
int ReadLine(int handle, char* buf, int bufsize);
|
|
int ReadData(int handle, char* buf, int bufsize);
|
|
void PrepareSelect( int fd1);
|
|
void PrepareSelect( int fd1, int fd2);
|
|
void PrepareSelect( int fd1, int fd2, int fd3);
|
|
int WaitFD(int timeoutms);
|
|
|
|
int m_filesize; // gesetzt durch 150 Antwort nach RETR
|
|
CNetPacket m_ETag; // check sum etag der aktuellen OPEN datei
|
|
CNetPacket m_LastModified; // Thu, 30 Nov 2006 11:17:20 GMT
|
|
|
|
bool m_winNtMode;
|
|
|
|
CNetPacket *m_pending; // Nicht kompletter Netbuffer
|
|
dequeue<CNetPacket> m_netbuf; // hier sitzen die geladen messages die
|
|
// noch nicht abgeholt sind
|
|
|
|
void DestroyBuffer();
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif //_HTTPCLIENT_H
|