From 661ce218a1775cfd08537117ed4d559948393668 Mon Sep 17 00:00:00 2001 From: Lao Ke <36225368+kehengzhong@users.noreply.github.com> Date: Mon, 28 Dec 2020 18:57:49 +0800 Subject: [PATCH] Add files via upload --- include/ejet.h | 14 +++++++++++--- include/http_cc.h | 28 ++++++++++++++++++++++++++++ include/http_do.h | 12 ------------ include/http_fcgi_io.h | 1 + include/http_fcgi_msg.h | 19 +++++++++++++------ include/http_msg.h | 11 +++++++++-- include/http_srv_io.h | 5 +++-- 7 files changed, 65 insertions(+), 25 deletions(-) create mode 100644 include/http_cc.h diff --git a/include/ejet.h b/include/ejet.h index 234a868..8020f54 100644 --- a/include/ejet.h +++ b/include/ejet.h @@ -178,6 +178,12 @@ typedef struct http_msg { int64 req_stream_sent; int64 req_stream_recv; + /* by adopting zero-copy for higher performance, frame buffers of HTTPCon, which stores + octets from sockets, will be moved to following list, for further parsing or handling, + when receiving octest from client connection and forwarding to origin server. + the overhead of memory copy will be lessened significantly. */ + arr_t * req_rcvs_list; + /* if content type of POST request is multipart form, every part is stored in list */ arr_t * req_formlist; void * req_form_json; @@ -273,7 +279,8 @@ typedef struct http_msg { int64 res_stream_recv; /* by adopting zero-copy for higher performance, frame buffers of HTTPCon, which stores - octets from sockets, will be moved to following list, for further parsing or handling. + octets from sockets, will be moved to following list, for further parsing or handling, + when receiving octest from origin server connection and forwarding to client. the overhead of memory copy will be lessened significantly. */ arr_t * res_rcvs_list; @@ -290,6 +297,7 @@ typedef struct http_msg { uint8 reshandle_called; void * reshandle_para; void * reshandle_cbval; + char * res_store_file; int64 res_store_offset; @@ -302,8 +310,8 @@ typedef struct http_msg { int (*SetTearDownNotify)(void * vmsg, void * func, void * para); int (*SetResponseHandle)(void * vmsg, void * func, void * para, void * cbval, - char * storefile, int64 offset, - void * procnotify, void * notifypara); + char * storefile, int64 offset, + void * procnotify, void * notifypara); char * (*GetMIME) (void * vmsg, char * extname, uint32 * mimeid); void * (*GetMIMEMgmt) (void * vmsg); diff --git a/include/http_cc.h b/include/http_cc.h new file mode 100644 index 0000000..ea87d68 --- /dev/null +++ b/include/http_cc.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2003-2021 Ke Hengzhong + * All rights reserved. See MIT LICENSE for redistribution. + */ + +#ifndef _HTTP_CONGESTION_H_ +#define _HTTP_CONGESTION_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +int http_cli_recv_cc (void * vcon); +int http_cli_send_cc (void * vcon); + +int http_srv_recv_cc (void * vcon); +int http_srv_send_cc (void * vcon); + +int http_fcgi_recv_cc (void * vcon); +int http_fcgi_send_cc (void * vcon); + +#ifdef __cplusplus +} +#endif + +#endif + + diff --git a/include/http_do.h b/include/http_do.h index 206c733..59bfe02 100644 --- a/include/http_do.h +++ b/include/http_do.h @@ -13,9 +13,6 @@ extern "C" { /* auto-redirect to new Location when response status is 301/302 */ int http_redirect_request (void * vmsg); -/* determine if the network is connected to */ -int http_net_active (void * vmgmt, int oldstate); - /* sending HTTP Request to HTTPServer and receiving the response */ int do_http_request (void * vmsg); @@ -25,10 +22,6 @@ void * do_http_get_msg (void * vmgmt, char * url, int urllen, void * do_http_get (void * vmgmt, char * url, int urllen, void * resfunc, void * para, void * cbval, void * rcvprocfunc, void * funcpara, char * resfile, long resoff); -void * origin_http_get (void * vmgmt, char * url, int urllen, void * resfunc, void * para, void * cbval, - void * rcvprocfunc, void * funcpara, char * resfile, - long resoff, uint64 start, uint64 size, char * route, char * opaque); - void * do_http_post_msg (void * vmgmt, char * url, int urllen, char * mime, char * body, int bodylen, @@ -44,11 +37,6 @@ void * do_http_post (void * vmgmt, char * url, int urllen, char * mime, void * rcvprocfunc, void * rcvpara, void * sndprocfunc, void * sndpara, char * resfile, long resoff); -void * do_http_range_get_msg (void * vmgmt, char * url, int urllen, - void * resfunc, void * para, void * cbval, - void * rcvprocfunc, void * funcpara, void * funccbval, - char * resfile, long resoff, uint64 start, uint64 size, char *route, char * opaque); - #ifdef __cplusplus } #endif diff --git a/include/http_fcgi_io.h b/include/http_fcgi_io.h index 919e23c..31f9c16 100644 --- a/include/http_fcgi_io.h +++ b/include/http_fcgi_io.h @@ -14,6 +14,7 @@ int http_fcgicon_crash_handle (void * vcon); int http_fcgi_send_probe (void * vcon); int http_fcgi_send (void * vcon); +int http_fcgi_send_final (void * vmsg); int http_fcgi_recv (void * vcon); int http_fcgi_recv_parse (void * vcon); diff --git a/include/http_fcgi_msg.h b/include/http_fcgi_msg.h index 26c8837..1c7b9f3 100644 --- a/include/http_fcgi_msg.h +++ b/include/http_fcgi_msg.h @@ -76,13 +76,18 @@ typedef struct fastcgi_msg_s { int req_body_flag; //BC_CONTENT_LENGTH or BC_TE int64 req_body_length; - void * req_chunk; - + int64 req_body_iolen; + int64 req_stream_sent; //total sent length including header and body - int64 req_header_sent; //body length that read or write already - int64 req_body_sent; //body length that read or write already uint8 reqsent; //0-not sent or in sending 1-already sent - + + /* by adopting zero-copy for higher performance, frame buffers of HTTPCon, which stores + octets from sockets, will be moved to following list, for further parsing or handling. + the overhead of memory copy will be lessened significantly. */ + arr_t * req_rcvs_list; + + /* the fragmented data blocks to be sent to CGI-Server are stored in chunk_t */ + chunk_t * req_body_chunk; unsigned fcgi_role : 16; unsigned fcgi_keep_alive : 1; @@ -170,11 +175,13 @@ int http_fcgimsg_abort_encode (void * vmsg); int http_fcgimsg_stdin_init (void * vmsg); int http_fcgimsg_stdin_encode (void * vmsg, void * pbyte, int bytelen, int end); -int http_fcgimsg_stdin_encode_end (void * vmsg); +int http_fcgimsg_stdin_end_encode (void * vmsg); int http_fcgimsg_stdin_body_sentnum (void * vmsg, int sentlen); int http_fcgimsg_pre_crash (void * vmsg, int status); +int http_fcgimsg_stdin_encode_chunk (void * vmsg, void * pbyte, int bytelen, void * porig, int end); +int http_fcgimsg_stdin_end_encode_chunk (void * vmsg); #ifdef __cplusplus } diff --git a/include/http_msg.h b/include/http_msg.h index 766e19c..26f5e4e 100644 --- a/include/http_msg.h +++ b/include/http_msg.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2020 Ke Hengzhong + * Copyright (c) 2003-2021 Ke Hengzhong * All rights reserved. See MIT LICENSE for redistribution. */ @@ -175,6 +175,12 @@ typedef struct http_msg { int64 req_stream_sent; int64 req_stream_recv; + /* by adopting zero-copy for higher performance, frame buffers of HTTPCon, which stores + octets from sockets, will be moved to following list, for further parsing or handling, + when receiving octest from client connection and forwarding to origin server. + the overhead of memory copy will be lessened significantly. */ + arr_t * req_rcvs_list; + /* if content type of POST request is multipart form, every part is stored in list */ arr_t * req_formlist; void * req_form_json; @@ -270,7 +276,8 @@ typedef struct http_msg { int64 res_stream_recv; /* by adopting zero-copy for higher performance, frame buffers of HTTPCon, which stores - octets from sockets, will be moved to following list, for further parsing or handling. + octets from sockets, will be moved to following list, for further parsing or handling, + when receiving octest from origin server connection and forwarding to client. the overhead of memory copy will be lessened significantly. */ arr_t * res_rcvs_list; diff --git a/include/http_srv_io.h b/include/http_srv_io.h index 7124540..6287500 100644 --- a/include/http_srv_io.h +++ b/include/http_srv_io.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003-2020 Ke Hengzhong + * Copyright (c) 2003-2021 Ke Hengzhong * All rights reserved. See MIT LICENSE for redistribution. */ @@ -11,7 +11,8 @@ extern "C" { #endif int http_srv_send_probe (void * vcon); -int http_srv_send (void * vcon); +int http_srv_send (void * vcon); +int http_srv_send_final (void * vmsg); int http_srv_recv (void * vcon);