📄 mt_http.h
字号:
/*****************************************************************************
** File Name: *
** Author: *
** Date: 2006/11/01 *
** Copyright: 2006 MTONE, Inc. All Rights Reserved. *
** Description: *
******************************************************************************
** Important Edit History *
** --------------------------------------------------------------------------*
** DATE NAME DESCRIPTION *
** 2006/11/01 Create *
*****************************************************************************/
#ifndef _MT_HTTP_H_
#define _MT_HTTP_H_
#ifdef __cplusplus
extern "C"
{
#endif
#include "mt_sock.h"
#include "sci_types.h"
#define HTTP_REQUEST_INFO_SIZE 3*1024+1
#define HTTP_RESPONSE_INFO_SIZE 3*1024
#define HTTP_HOSTNAME_HOST_SIZE 64
#define HTTP_HOSTNAME_PORT_SIZE 6
// Accept: application/vnd.wap.mms-message, application/vnd.wap.wmlc, image/gif, image/jpeg, */*
// Accept: image/gif, image/jpeg, */*
// Referer: http://www.mtone.com.cn
// Accept-Language: zh-cn
// Accept-Encoding: deflate
// User-Agent: Mozilla/4.0 (compatible)
// User-Agent: Nokia7650/1.0 SymbianOS/6.1 Series60/0.9 Profile/MIDP-1.0 Configuration/CLDC-1.0
// Host: www.mtone.com.cn
// Range: bytes=0-
// Connection: close
#define HTTP_USER_AGENT_VALUEM "Mozilla/4.0 (compatible)"
#define HTTP_USER_AGENT_VALUEN "Nokia7650/1.0 SymbianOS/6.1 Series60/0.9 Profile/MIDP-1.0 Configuration/CLDC-1.0"
#define HTTP_HEADERSM "Accept: image/gif, image/jpeg, */*\r\nReferer: http://www.mtone.com.cn\r\nAccept-Language: zh-cn\r\nAccept-Encoding: deflate\r\nUser-Agent: Mozilla/4.0 (compatible)\r\nHost: www.mtone.com.cn\r\nRange: bytes=0-\r\nConnection: close\r\n"
#define HTTP_HEADERSN "Accept: image/gif, image/jpeg, */*\r\nReferer: http://www.mtone.com.cn\r\nAccept-Language: zh-cn\r\nAccept-Encoding: deflate\r\nUser-Agent: Nokia7650/1.0 SymbianOS/6.1 Series60/0.9 Profile/MIDP-1.0 Configuration/CLDC-1.0\r\nHost: www.mtone.com.cn\r\nRange: bytes=0-\r\nConnection: close\r\n"
#define HTTP_HEADERSNC "Accept: application/vnd.wap.mms-message, application/vnd.wap.wmlc, image/gif, image/jpeg, */*\r\nReferer: http://www.mtone.com.cn\r\nAccept-Language: zh-cn\r\nAccept-Encoding: deflate\r\nUser-Agent: Nokia7650/1.0 SymbianOS/6.1 Series60/0.9 Profile/MIDP-1.0 Configuration/CLDC-1.0\r\nHost: www.mtone.com.cn\r\nRange: bytes=0-\r\nConnection: close\r\n"
typedef struct
{
HSOCKETX m_hsockx;
char m_szHttpRequestInfo[HTTP_REQUEST_INFO_SIZE];
uint8 m_pHttpResponseInfo[HTTP_RESPONSE_INFO_SIZE];
uint16 m_nHttpResponseInfoLength;
uint16 m_nHttpResponseStatusLength;
uint16 m_nHttpResponseHeadersLength;
uint32 m_nHttpResponseBodyReadLength;
} HTTP, *HHTTP;
HHTTP HttpConnect( const char *szServerName, uint16 nServerPort );
int HttpCancel( HHTTP hHttp );
void HttpClose( HHTTP hHttp );
BOOLEAN HttpIsAvailable( HHTTP hHttp );
BOOLEAN HttpIsTimeout( HHTTP hHttp );
BOOLEAN HttpQueryResponseBodyReadLength( HHTTP hHttp, uint32 *pBodyReadLength );
BOOLEAN HttpOpen( HHTTP hHttp, const char *szVerb, const char *szObjectName, const char *szVersion, const char *szHeaders, const uint8 *pOptional, uint16 nOptionalLength, long nTimeout );
BOOLEAN HttpOpenUrlByGet ( HHTTP hHttp, const char *szUrl, const char *szHeaders, long nTimeout );
BOOLEAN HttpOpenUrlByHead( HHTTP hHttp, const char *szUrl, const char *szHeaders, long nTimeout );
BOOLEAN HttpOpenUrlByPost( HHTTP hHttp, const char *szUrl, const char *szHeaders, const uint8 *pBuffer, uint16 nBufferLength, long nTimeout );
BOOLEAN HttpReadResponseStatusAndHeaders( HHTTP hHttp, char *szStatus, uint16 nStatusSize, char *szHeaders, uint16 nHeadersSize, long nTimeout );
// BOOLEAN HttpReadResponseBody( HHTTP hHttp, uint8 *pBuffer, uint16 nNumberOfByteToRead, uint16 *nNumOfByteRead, long nTimeout );
BOOLEAN HttpReadResponseBody( HHTTP hHttp, uint8 *pBuffer, uint16 nNumberOfByteToRead, uint16 *nNumOfByteRead, long nTimeout, void (*OnDataFunc)( uint16, void * ), void *pUser );
BOOLEAN HttpUrlCrack( const char *szUrl, char *szHostName, uint8 nHostNameSize, uint16 *nPort, char *szUrlPath, uint16 nUrlPathSize );
BOOLEAN HttpUrlGenCT( char *szUrlCT, uint16 nUrlCTSize, const char *szUrlCN, const char *szHostName, const char *szTag );
BOOLEAN HttpHeadersAddHeader( char *szHeaders, uint16 nHeadersSize, const char *szFieldName, const char *szFieldValue );
void HttpHeadersRemoveHeader( char *szHeaders, const char *szFieldName );
BOOLEAN HttpHeadersSetHeader( char *szHeaders, uint16 nHeadersSize, const char *szFieldName, const char *szFieldValue );
BOOLEAN HttpHeadersSetHeaderRange( char *szHeaders, uint16 nHeadersSize, uint32 nRangeBegin, uint32 nRangeEnd );
void HttpHeadersGetHeader( const char *szHeaders, const char *szFieldName, char *szFieldValue, uint16 nFieldValueSize );
BOOLEAN HttpHeadersGetHeaderContentLength( const char *szHeaders, uint32 *pContentLength );
BOOLEAN HttpHeadersGetHeaderContentRange( const char *szHeaders, uint32 *pContentRangeBegin, uint32 *pContentRangeEnd, uint32 *pContentRangeTotal );
#ifdef __cplusplus
}
#endif
#endif // _MT_HTTP_H_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -