资源简介
纯C语言实现https的post和get,不依赖任何库。支持window,linux等多平台,因此get及post效率较高,可移植性很好。本次上传的是vc6下的完整工程的压缩包,解压后可直接使用。若要在linux下编译和运行,可按照压缩包内Linux下编译运行https的帮助文档来操作。
![](http://www.nz998.com/pic/71300.jpg)
代码片段和文件信息
#include “http.h“
#include “http_parser.h“
#include
#include
#include
#ifdef WIN32
#include
#ifdef WINCE
#pragma comment( lib “ws2.lib“)
#else
#pragma comment( lib “ws2_32.lib“)
#endif
#else
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define _strdup strdup
#define _stricmp strcasecmp
#define _strnicmp strncasecmp
#endif
#if FT_SUPPORT_HTTPS
#ifdef USEOPENSSL
#include
#include
#else
#include “krypton.h“
#endif
#endif
const int kSelectRead = 1 << 0;
const int kSelectWrite = 1 << 1;
const int kSelectError = 1 << 2;
#define DEFAULT_USER_AGENT_STR “User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 Firefox/29.0\r\n“
#define CONNECT_STR “Connection: close\r\n“
#define ACCEPT_STR “Accept: */*\r\n“
#define CONTENT_LENGTH_STR “Content-Length“
#define CONTENT_TYPE_STR “Content-Type:application/x-www-form-urlencoded\r\n“
#define CONTENT_DISPOSITION_STR “Content-Disposition“
#define CRLF “\r\n“
enum parser_statue_e { PARSERD_NONE = 0 PARSERD_FIELD PARSERD_VALUE PARSERD_BODY };
enum proto_type_e { PROTO_HTTP = 0 PROTO_HTTPS };
#ifdef WIN32
typedef SOCKET socket_t;
#define HTTP_INVALID_SOCKET INVALID_SOCKET
#define HTTP_EINTR WSAEINTR
#define HTTP_EINPROGRESS WSAEINPROGRESS
#define HTTP_EWOULDBLOCK WSAEWOULDBLOCK
#define HTTP_EALREADY WSAEALREADY
#else
typedef int socket_t;
#define HTTP_INVALID_SOCKET -1
#define HTTP_EINTR EINTR
#define HTTP_EINPROGRESS EINPROGRESS
#define HTTP_EWOULDBLOCK EWOULDBLOCK
#define HTTP_EALREADY EALREADY
#endif
#define RECV_BUF_SIZE 4 * 1024
struct ft_http_client_t
{
FILE* pf;
char* filename;
char* body;
char* redirect_url;
char* header_field;
char* header_value;
char* user;
data_recv_cb_t recv_cb;
unsigned long body_len;
unsigned long content_length;
enum http_request_method_e method;
enum proto_type_e proto_type;
unsigned short field_size;
unsigned short value_size;
unsigned short cur_field_size;
unsigned short cur_value_size;
#if FT_SUPPORT_HTTPS
SSL_CTX *ctx;
SSL *ssl;
#endif
socket_t fd;
int timeout;
short status_code;
char parser_statue;
char error_code;
unsigned cancel : 1;
unsigned exit : 1;
unsigned download : 1;
unsigned redirect : 1;
};
#ifdef WIN32
#define socket_close closesocket
#else
#define socket_close close
#endif
#define free_member(member) if((member)) { free(member); (member) = NULL; }
#define close_socket(fd) if(fd != HTTP_INVALID_SOCKET) { socket_close(fd); fd = HTTP_INVALID_SOCKET; }
#define close_file(pf) if
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 45287 2018-08-02 08:43 https\Debug\http.obj
文件 77902 2018-08-02 08:43 https\Debug\http_parser.obj
文件 225729 2018-08-02 08:43 https\Debug\krypton.obj
文件 352324 2018-08-02 09:09 https\Debug\main.exe
文件 304744 2018-08-02 09:09 https\Debug\main.ilk
文件 4693 2018-08-02 09:09 https\Debug\main.obj
I.A.... 185200 2018-08-02 09:09 https\Debug\main.pch
文件 828416 2018-08-02 09:09 https\Debug\main.pdb
文件 50176 2018-08-02 09:09 https\Debug\vc60.idb
文件 86016 2018-08-02 09:09 https\Debug\vc60.pdb
I.A.... 22529 2018-07-26 09:03 https\http.c
I.A.... 2221 2018-07-25 20:05 https\http.h
文件 74049 2018-08-01 16:02 https\http_parser.c
文件 13513 2018-08-01 16:01 https\http_parser.h
文件 22141 2018-08-02 09:09 https\img.jpg
文件 241070 2018-08-01 16:01 https\krypton.c
文件 2908 2018-08-01 16:02 https\krypton.h
文件 376 2018-08-02 09:17 https\Linux下编译运行https帮助文档.txt
文件 944 2018-08-02 09:09 https\main.c
文件 3749 2018-08-01 16:14 https\main.dsp
文件 514 2018-08-01 16:14 https\main.dsw
文件 115712 2018-08-02 09:09 https\main.ncb
文件 49664 2018-08-02 09:09 https\main.opt
文件 1196 2018-08-02 09:09 https\main.plg
目录 0 2018-08-02 09:09 https\Debug
目录 0 2019-12-24 14:15 https
----------- --------- ---------- ----- ----
2711073 26
- 上一篇:论文研究-GNSS接收机上位机软件设计 .pdf
- 下一篇:多边形有效边表填充算法
相关资源
- C++中头文件与源文件的作用详解
- C语言代码高亮html输出工具
- 猜数字游戏 c语言代码
- C语言课程设计
- 数字电位器C语言程序
- CCS FFT c语言算法
- 使用C语言编写的病房管理系统
- 通信过程中的RS编译码程序(c语言)
- 计算机二级C语言上机填空,改错,编
- 用回溯法解决八皇后问题C语言实现
- 简易教务管理系统c语言开发文档
- 操作系统课设 读写者问题 c语言实现
- 小波变换算法 c语言版
- C流程图生成器,用C语言代码 生成C语
- 3des加密算法C语言实现
- 简单的C语言点对点聊天程序
- 单片机c语言源程序(51定时器 八个按
- 个人日常财务管理系统(C语言)
- c语言电子商务系统
- 小甲鱼C语言课件 源代码
- 将图片转换为C语言数组的程序
- C语言实现的一个内存泄漏检测程序
- DES加密算法C语言实现
- LINUX下命令行界面的C语言细胞游戏
- 用单片机控制蜂鸣器播放旋律程序(
- 学校超市选址问题(数据结构C语言版
- 电子时钟 有C语言程序,PROTEUS仿真图
- 尚观培训linux许巍老师关于c语言的课
- 算符优先语法分析器(C语言编写)
- 基于C语言的密码锁程序
评论
共有 条评论