#include "read_winhttp.h"
#define DEMO 3
int main()
{
#if DEMO == 1
//multipart/form-data
char* proxy = NULL;
char* user = NULL;
char* pass = NULL;
char* url = "https://ip.cn/";
int mode = 3; //1/2/3 GET/POST/multipart/form-data
BOOL refirect = TRUE; //自动重定向
char* cookie = NULL;
char* data = "aa=11&bb=22";
int data_len = strlen(data);
char* upload_source = "filename";
char* upload_filename = "1.jpg";
char* upload_type = "image/jpeg";
char* upload_buffer = "aa";
int len_upload_buffer = strlen(upload_buffer);
WCHAR* w_add_request_headers[] = { L"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
L"Referer: https://bbs.pediy.com/",
NULL};
#elif DEMO == 2
//POST
char* proxy = NULL;
char* user = NULL;
char* pass = NULL;
char* url = "https://ip.cn/";
int mode = 2; //1/2/3 GET/POST/multipart/form-data
BOOL refirect = TRUE; //自动重定向
char* cookie = NULL;
char* data = "aa=11&bb=22";
int data_len = strlen(data);
char* upload_source = NULL;
char* upload_filename = NULL;
char* upload_type = NULL;
char* upload_buffer = NULL;
int len_upload_buffer = 0;
WCHAR* w_add_request_headers[] = { L"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
L"Referer: https://bbs.pediy.com/",
NULL};
#elif DEMO == 3
//GET
char* proxy = NULL;
char* user = NULL;
char* pass = NULL;
char* url = "https://ip.cn/";
int mode = 1; //1/2/3 GET/POST/multipart/form-data
BOOL refirect = TRUE; //自动重定向
char* cookie = NULL;
char* data = NULL;
int data_len = 0;
char* upload_source = NULL;
char* upload_filename = NULL;
char* upload_type = NULL;
char* upload_buffer = NULL;
int len_upload_buffer = 0;
WCHAR* w_add_request_headers[] = { L"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3",
L"Referer: https://bbs.pediy.com/",
NULL};
#endif
string strHeader = "";
string strBody = "";
if (read_winhttp(proxy, user, pass, url, mode, refirect, cookie,
data, data_len,
upload_source, upload_filename, upload_type, upload_buffer, len_upload_buffer,
w_add_request_headers,strHeader, strBody))
{
puts(strHeader.c_str());
puts(strBody.c_str());
}
return 1;
}