mirror of
https://github.com/siemens-mobile-hacks/sieelf.git
synced 2026-11-25 22:27:29 +00:00
70 lines
1 KiB
C++
70 lines
1 KiB
C++
/*
|
|
Ïðîåêò SieGet Downloader
|
|
*/
|
|
#include "..\inc\swilib.h"
|
|
#include "socket.h"
|
|
#include "inet.h"
|
|
|
|
void HttpGet::Start(const char *_req, int _ip, short _port)
|
|
{
|
|
req = _req;
|
|
ip = _ip;
|
|
port = _port;
|
|
buf = new char[1024];
|
|
buf_size = 1024;
|
|
recvsize = 0;
|
|
Connect(ip, port);
|
|
}
|
|
|
|
void HttpGet::onCreate()
|
|
{
|
|
}
|
|
|
|
void HttpGet::onConnected()
|
|
{
|
|
Send(req, strlen(req));
|
|
}
|
|
|
|
void HttpGet::onDataRead()
|
|
{
|
|
char tmpbuf[1024];
|
|
int nrecv = Recv(tmpbuf, 1024);
|
|
if (recvsize+nrecv>buf_size-4)
|
|
{
|
|
buf = (char *)realloc(buf, buf_size+1024);
|
|
buf_size += 1024;
|
|
}
|
|
memcpy(buf+recvsize, tmpbuf, nrecv);
|
|
recvsize += nrecv;
|
|
}
|
|
|
|
void HttpGet::onClose()
|
|
{
|
|
#warning Íàäî áû óáðàòü ýòó çàãëóøêó...
|
|
body = buf;
|
|
body_size = recvsize;
|
|
onFinish(RECV_RESULT_OK);
|
|
}
|
|
|
|
void HttpGet::onRemoteClose()
|
|
{
|
|
Close();
|
|
}
|
|
|
|
void HttpGet::onError(SOCK_ERROR err)
|
|
{
|
|
onFinish(RECV_RESULT_ERROR);
|
|
}
|
|
|
|
HttpGet::HttpGet(SocketHandler *handler)
|
|
:Socket(handler)
|
|
{
|
|
|
|
}
|
|
|
|
HttpGet::~HttpGet()
|
|
{
|
|
|
|
}
|
|
|
|
|