Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
kehengzhong authored Dec 8, 2020
1 parent 5e3a78d commit 40aa5fe
Show file tree
Hide file tree
Showing 63 changed files with 28,016 additions and 0 deletions.
563 changes: 563 additions & 0 deletions include/ejet.h

Large diffs are not rendered by default.

110 changes: 110 additions & 0 deletions include/http_cache.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
/*
* Copyright (c) 2003-2020 Ke Hengzhong <[email protected]>
* All rights reserved. See MIT LICENSE for redistribution.
*/

#ifndef _HTTP_CACHE_H_
#define _HTTP_CACHE_H_

#ifdef __cplusplus
extern "C" {
#endif

/* HTTP Cache storage system includes raw files and cache information file.
raw files are actual origin server files cached in local storage in Web Server.
cache information file is accompanied by the raw file. its name is extended from
raw file with .cache. each raw file directory must have a cache directory with hiding
attribute and all cache information files are saved here. */

/* cache facilities:
Expires: Wed, 21 Oct 2020 07:28:00 GMT (Response Header)
Cache-Control: max-age=73202 (Response Header)
Cache-Control: public, max-age=73202 (Response Header)
Last-Modified: Mon, 18 Dec 2019 12:35:00 GMT (Response Header)
If-Modified-Since: Fri, 05 Jul 2019 02:14:23 GMT (Request Header)
ETag: 627Af087-27C8-32A9E7B10F (Response Header)
If-None-Match: 627Af087-27C8-32A9E7B10F (Request Header)
*/

/* 96 bytes header of cache information file */

typedef struct cache_info_s {

CRITICAL_SECTION cacheCS;

char * cache_file;
char * cache_tmp;

char * info_file;
void * hinfo;

uint32 mimeid;
uint8 body_flag;
int header_length;
int64 body_length;
int64 body_rcvlen;

/* Cache-Control: max-age=0, private, must-revalidate
Cache-Control: max-age=7200, public
Cache-Control: no-cache */
uint8 directive; //0-max-age 1-no cache 2-no store
uint8 revalidate; //0-none 1-must-revalidate
uint8 pubattr; //0-unknonw 1-public 2-private(only browser cache)

time_t ctime;
time_t expire;
int maxage;
time_t mtime;
char etag[36];

FragPack * frag;

int count;

void * httpmgmt;
} CacheInfo;

void * cache_info_alloc ();
void cache_info_free (void * vcacinfo);

int cache_info_zero (void * vcacinfo);

int64 cache_info_body_length (void * vcacinfo);

int cache_info_read (void * vcacinfo);

int cache_info_write_meta (void * vcacinfo);
int cache_info_write_frag (void * vcacinfo);
int cache_info_write (void * vcacinfo);

int cache_info_add_frag (void * vcacinfo, int64 pos, int64 len, int complete);

int cache_info_verify (void * vcacinfo);


int http_request_cache_init (void * vmsg);
int http_response_cache_init (void * vmsg);

int http_request_in_cache (void * vmsg);
int http_proxy_cache_open (void * vmsg);
int http_proxy_cache_parse (void * vmsg, void * vclimsg, int * resend);

int http_proxy_cache_complete (void * vmsg);
int http_cache_response_header (void * vmsg, void * vcacinfo);

int http_cache_info_init (void * vmgmt);
int http_cache_info_clean (void * vmgmt);

void * cache_info_open (void * vmgmt, char * cacfile);
void * cache_info_create (void * vmgmt, char * cacfile, int64 fsize);
void cache_info_close (void * vcacinfo);


#ifdef __cplusplus
}
#endif

#endif

183 changes: 183 additions & 0 deletions include/http_cgi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
/*
* Copyright (c) 2003-2020 Ke Hengzhong <[email protected]>
* All rights reserved. See MIT LICENSE for redistribution.
*/

#ifndef _HTTP_CGI_H_
#define _HTTP_CGI_H_

#ifdef __cplusplus
extern "C" {
#endif


void * GetHTTPMgmt (void * vmsg);
void * GetEPump (void * vmsg);
void * GetIODev (void * vmsg);

frame_p GetFrame (void * vmsg);
int RecycleFrame (void * vmsg, frame_p frame);

char * GetRootPath (void * vmsg);

int GetPathP (void * vmsg, char ** ppath, int * pathlen);
int GetReqPath (void * vmsg, char * path, int pathlen);
int GetRealPath (void * vmsg, char * path, int pathlen);
int GetRealFile (void * vmsg, char * path, int pathlen);
int GetLocFile (void * vmsg, char * p, int len, char * f, int flen, char * d, int dlen);
int GetPathOnly (void * vmsg, char * path, int pathlen);
int GetFileOnly (void * vmsg, char * path, int pathlen);
int GetFileExt (void * vmsg, char * path, int pathlen);

char * GetMethod (void * vmsg);
int GetBaseURL (void * vmsg, char ** pbase, int * plen);
char * GetAbsURL (void * vmsg);
char * GetRelative (void * vmsg);
char * GetURL (void * vmsg);
char * GetDocURL (void * vmsg);

int GetSchemeP (void * vmsg, char ** pscheme, int * schemelen);
int GetScheme (void * vmsg, char * scheme, int schemelen);
int GetHostP (void * vmsg, char ** phost, int * hostlen);
int GetHost (void * vmsg, char * host, int hostlen);
int GetPort (void * vmsg);

int GetQueryP (void * vmsg, char ** pquery, int * pquerylen);
int GetQuery (void * vmsg, char * query, int querylen);
int GetQueryValueP (void * vmsg, char * key, char ** pval, int * vallen);
int GetQueryValue (void * vmsg, char * key, char * val, int vallen);
int GetQueryUint (void * vmsg, char * key, uint32 * val);
int GetQueryInt (void * vmsg, char * key, int * val);
int GetQueryUlong (void * vmsg, char * key, ulong * val);
int GetQueryInt64 (void * vmsg, char * key, int64 * val);
int GetQueryUint64 (void * vmsg, char * key, uint64 * val);
int GetQueryLong (void * vmsg, char * key, long * val);
int GetQueryKeyExist (void * vmsg, char * key);

int GetReqContent (void * vmsg, void * body, int bodylen);
int GetReqContentP (void * vmsg, void ** pbody, int * bodylen);

int GetReqFormJsonValueP (void * vmsg, char * key, char ** ppval, int * vallen);
int GetReqFormJsonValue (void * vmsg, char * key, char * pval, int vallen);
int GetReqFormJsonKeyExist (void * vmsg, char * key);

int GetReqFormDecodeValueP (void * vmsg, char * key, char ** ppval, int * vallen);
int GetReqFormDecodeValue (void * vmsg, char * key, char * pval, int vallen);

int GetReqFormValueP (void * vmsg, char * key, char ** ppval, int * vallen);
int GetReqFormValue (void * vmsg, char * key, char * pval, int vallen);
int GetReqFormUint (void * vmsg, char * key, uint32 * val);
int GetReqFormInt (void * vmsg, char * key, int * val);
int GetReqFormUlong (void * vmsg, char * key, ulong * val);
int GetReqFormLong (void * vmsg, char * key, long * val);
int GetReqFormUint64 (void * vmsg, char * key, uint64 * val);
int GetReqFormKeyExist (void * vmsg, char * key);

int GetReqHdrNum (void * vmsg);
int GetReqHdrIndP (void * vmsg, int index, char ** pname, int * namelen,
char ** pvalue, int * valuelen);
int GetReqHdrInd (void * vmsg, int index, char * name, int namelen,
char * value, int valuelen);
int GetReqHdr (void * vmsg, char * name, int namelen, char * value, int valuelen);
int GetReqHdrP (void * vmsg, char * name, int namelen, char ** pval, int * vallen);

int GetReqHdrInt (void * vmsg, char * name, int namelen);
long GetReqHdrLong (void * vmsg, char * name, int namelen);
ulong GetReqHdrUlong (void * vmsg, char * name, int namelen);
int64 GetReqHdrInt64 (void * vmsg, char * name, int namelen);
uint64 GetReqHdrUint64 (void * vmsg, char * name, int namelen);

int GetReqContentTypeP (void * vmsg, char ** ptype, int * typelen);
int GetReqContentType (void * vmsg, char * type, int typelen);
int GetReqContentLength (void * vmsg);

int GetReqEtag (void * vmsg, char * etag, int etaglen);
int GetCookieP (void * vmsg, char * name, int nlen, char ** pv, int * vlen);
int GetCookie (void * vmsg, char * name, int nlen, char * val, int vlen);

int AddReqHdr (void * vmsg, char * name, int namelen, char * value, int valuelen);
int AddReqHdrInt (void * vmsg, char * name, int namelen, int value);
int AddReqHdrUint32 (void * vmsg, char * name, int namelen, uint32 value);
int AddReqHdrLong (void * vmsg, char * name, int namelen, long value);
int AddReqHdrUlong (void * vmsg, char * name, int namelen, ulong value);
int AddReqHdrInt64 (void * vmsg, char * name, int namelen, int64 value);
int AddReqHdrUint64 (void * vmsg, char * name, int namelen, uint64 value);
int AddReqHdrDate (void * vmsg, char * name, int namelen, time_t dtime);
int DelReqHdr (void * vmsg, char * name, int namelen);

int SetResEtag (void * vmsg, char * etag, int etaglen);
int SetCookie (void * vmsg, char * name, char * value, time_t expire,
char * path, char * domain, uint8 secure);

int SetReqContentType (void * vmsg, char * type, int typelen);
int SetReqContentLength (void * vmsg, int64 len);
int SetReqContent (void * vmsg, void * body, int bodylen);
int SetReqFileContent (void * vmsg, char * filename);

int AddReqContent (void * vmsg, void * body, int64 bodylen);
int AddReqContentPtr (void * vmsg, void * body, int64 bodylen);
int AddReqFile (void * vmsg, char * filename, int64 startpos, int64 len);
int AddReqAppCBContent (void * vmsg, void * fetchfunc, void * fetchobj, int64 offset, int64 length,
void * movefunc, void * movepara, void * endfetch, void * endobj);


int GetResHdrNum (void * vmsg);
int GetResHdrIndP (void * vmsg, int index, char ** pname, int * namelen,
char ** pvalue, int * valuelen);
int GetResHdrInd (void * vmsg, int index, char * name, int namelen,
char * value, int valuelen);
int GetResHdr (void * vmsg, char * name, int namelen, char * value, int valuelen);
int GetResHdrP (void * vmsg, char * name, int namelen, char ** pval, int * vallen);

int GetResHdrInt (void * vmsg, char * name, int namelen);
long GetResHdrLong (void * vmsg, char * name, int namelen);
ulong GetResHdrUlong (void * vmsg, char * name, int namelen);
int64 GetResHdrInt64 (void * vmsg, char * name, int namelen);
uint64 GetResHdrUint64 (void * vmsg, char * name, int namelen);

int GetResContentTypeP (void * vmsg, char ** ptype, int * typelen);
int GetResContentType (void * vmsg, char * type, int typelen);
int GetResContentTypeID (void * vmsg, uint32 * mimeid, char ** pext);
int64 GetResContentLength (void * vmsg);

int GetResContent (void * vmsg, void * body, int bodylen);
int GetResContentP (void * vmsg, int64 pos, void ** pbody, int64 * bodylen);

int GetStatus (void * vmsg, char * reason, int * reasonlen);

int SetStatus (void * vmsg, int code, char * reason);

int AddResHdr (void * vmsg, char * name, int namelen, char * value, int valuelen);
int AddResHdrInt (void * vmsg, char * name, int namelen, int value);
int AddResHdrUint32 (void * vmsg, char * name, int namelen, uint32 value);
int AddResHdrLong (void * vmsg, char * name, int namelen, long value);
int AddResHdrUlong (void * vmsg, char * name, int namelen, ulong value);
int AddResHdrInt64 (void * vmsg, char * name, int namelen, int64 value);
int AddResHdrUint64 (void * vmsg, char * name, int namelen, uint64 value);
int AddResHdrDate (void * vmsg, char * name, int namelen, time_t dtime);
int DelResHdr (void * vmsg, char * name, int namelen);

int Check304Resp (void * vmsg, uint64 mediasize, time_t mtime, uint32 inode);

int SetResContentType (void * vmsg, char * type, int typelen);
int SetResContentTypeID (void * vmsg, uint32 mimeid);
int SetResContentLength (void * vmsg, int64 len);

int AddResContent (void * vmsg, void * body, int64 bodylen);
int AddResStripContent (void * vmsg, void * body, int64 bodylen, char * escch, int chlen);
int AddResContentPtr (void * vmsg, void * body, int64 bodylen);
int AddResFile (void * vmsg, char * filename, int64 startpos, int64 len);
int AddResAppCBContent (void * vmsg, void * fetchfunc, void * fetchobj, int64 offset, int64 length,
void * movefunc, void * movepara, void * endfetch, void * endobj);

int Reply (void * vmsg);
int ReplyFeeding (void * vmsg);
int RedirectReply (void * vmsg, int status, char * url);

#ifdef __cplusplus
}
#endif

#endif


81 changes: 81 additions & 0 deletions include/http_chunk.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* Copyright (c) 2003-2020 Ke Hengzhong <[email protected]>
* All rights reserved. See MIT LICENSE for redistribution.
*/

#ifndef _HTTP_CHUNK_H_
#define _HTTP_CHUNK_H_

#include "chunk.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef struct http_buf {
uint8 * pbgn;
int len;

uint8 * body_bgn;
int body_len;

uint8 alloc;
} HTTPBuf;

typedef struct http_chunk_item {
int64 chksize;
int64 chklen;

int64 recvsize;
int64 recvlen;

uint8 gotall;

arr_t * buf_list;

} HTTPChunkItem;

typedef struct http_chunk {

uint8 gotall;
uint8 gotallbody;

int64 chksize; //byte num including chunk size line, chunk body, chunk header, trailer
int64 chklen; //actual, available content
int64 recvsize; //byte num including chunk size line, chunk body, chunk header, trailer
int64 recvlen; //actual, available content
int chknum;

/* if the chunk got all bytes, append it to list */
HTTPChunkItem * curitem;

arr_t * item_list;

int enthdrsize;
HTTPBuf * enthdr;

chunk_t * chunk;

} HTTPChunk;


void * http_chunk_alloc ();
void http_chunk_free (void * vchk);

int http_chunk_zero (void * vchk);
void * http_chunk_dup (void * vchk);

chunk_t * http_chunk_obj (void * vchk);

int http_chunk_add_bufptr (void * vchk, void * pbgn, int len, int * rmlen);

int http_chunk_gotall (void * vchk);


#ifdef __cplusplus
}
#endif

#endif


Loading

0 comments on commit 40aa5fe

Please sign in to comment.