|
JunkBox_Lib 1.10.1
|
HTTP ツールライブラリ ヘッダ More...


Go to the source code of this file.
Macros | |
| #define | HTTP_CONNECTION_CLOSE 0 |
| #define | HTTP_CONNECTION_KEEP 1 |
| #define | HTTP_HEADER_NOT_HTTP -1990 |
| #define | HTTP_HEADER_CLOSED_SESSION -1997 |
| #define | HTTP_HEADER_CHUNKED -1998 |
| #define | HTTP_HEADER_UNKNOWN_LEN -1999 |
| #define | HTTP_ERROR_METHOD -1 |
| HTTP で無い場合は負数にする. | |
| #define | HTTP_UNKNOWN_METHOD 0 |
| 0 固定.これ以下はエラーとする. | |
| #define | HTTP_GET_METHOD 1 |
| #define | HTTP_PUT_METHOD 2 |
| #define | HTTP_POST_METHOD 3 |
| #define | HTTP_DELETE_METHOD 4 |
| #define | HTTP_OPTIONS_METHOD 5 |
| #define | HTTP_HEAD_METHOD 6 |
| #define | HTTP_TRACE_METHOD 7 |
| #define | HTTP_CONNECT_METHOD 8 |
| #define | HTTP_PATCH_METHOD 9 |
| #define | HTTP_LINK_METHOD 10 |
| #define | HTTP_UNLINK_METHOD 11 |
| #define | HTTP_PROPFIND_METHOD 20 |
| #define | HTTP_PROPPATCH_METHOD 21 |
| #define | HTTP_MKCOL_METHOD 22 |
| #define | HTTP_COPY_METHOD 23 |
| #define | HTTP_MOVE_METHOD 24 |
| #define | HTTP_LOCK_METHOD 25 |
| #define | HTTP_UNLOCK_METHOD 26 |
| #define | HTTP_RESPONSE_METHOD 99 |
| #define | HTTP_TIMEOUT 60 |
| 秒 | |
| #define | HTTP_RESPONSE_TIMEOUT 180 |
| 秒 | |
| #define | HTTP_PROXY_TIMEOUT 60 |
| 秒 | |
Functions | |
| int | recv_http_header (int sock, tList **pl, int *len, int tm, FILE *fp, int *state) |
| int | send_http_header (int sock, tList *pl, int mode) |
| int | recv_http_content (int sofd, Buffer *buf, int len, int tm, FILE *fp, int *state) |
| int | recv_http_chunked (int sofd, Buffer *buf, int tm, FILE *fp, int *state) |
| int | recv_http_closed (int sofd, Buffer *buf, int tm, FILE *fp) |
| int | recv_http_chunked_remain (int sofd, Buffer *buf, int chnksz, int tm) |
| int | recv_http_Buffer (int sock, tList **pl, Buffer *buf, int timeout, int *hdonly, int *state, int nochunk) |
| int | send_http_Buffer (int sock, tList *pl, Buffer *buf) |
| int | recv_http_file (int sock, tList **pl, const char *fn, const char *wdir, int timeout, int *hdonly, int *state) |
| int | send_http_file (int sock, tList *pl, const char *fn) |
| int | save_http_xml (int sock, tList **pl, tXML **xml, char **recvfn, const char *wdir, int timeout, int *state) |
| int | get_http_method (char *data) |
| int | is_http_header_field (tList *pl, char *field, char *value, int n) |
| int | get_http_header_method (tList *pl) |
| void | set_http_host_header (tList *pl, char *hname, unsigned short hport) |
| void | dump_http_header (FILE *fp, tList *pp) |
| int | get_http_status_num (tList *pl) |
| float | get_http_version_num (tList *pl) |
| int | get_chunked_size (char *ptr, int *hdsz, int *tlsz) |
| char * | get_http_header_date (time_t tm) |
| Buffer | rebuild_http_Buffer (tList *pl, Buffer *buf) |
| void | simple_web_proxy (int bofd, char *myip, int tmout) |
| int | www2browser_relay (int bofd, int wofd, int btm, int wtm, int keep) |
| Buffer | http_proxy_header_analyze (tList *pl, Buffer *server, unsigned short *sport, int *timeout, int *keep) |
| int | tcp_relay (int sofd, int cofd, int tm) |
| int | send_http_res_file (int sock, char *fn, int mode) |
| void | send_http_passwd_req (int sock) |
Definition in file http_tool.h.
| #define HTTP_CONNECT_METHOD 8 |
Definition at line 41 of file http_tool.h.
Referenced by get_http_method().
| #define HTTP_CONNECTION_CLOSE 0 |
Definition at line 22 of file http_tool.h.
Referenced by send_http_res_file().
| #define HTTP_CONNECTION_KEEP 1 |
Definition at line 23 of file http_tool.h.
| #define HTTP_COPY_METHOD 23 |
Definition at line 50 of file http_tool.h.
Referenced by get_http_method().
| #define HTTP_DELETE_METHOD 4 |
Definition at line 37 of file http_tool.h.
Referenced by get_http_method().
| #define HTTP_ERROR_METHOD -1 |
Definition at line 30 of file http_tool.h.
| #define HTTP_GET_METHOD 1 |
Definition at line 34 of file http_tool.h.
Referenced by get_http_method(), and recv_http_header().
| #define HTTP_HEAD_METHOD 6 |
Definition at line 39 of file http_tool.h.
Referenced by get_http_method().
| #define HTTP_HEADER_CHUNKED -1998 |
Definition at line 26 of file http_tool.h.
Referenced by recv_http_Buffer(), recv_http_file(), recv_http_header(), and www2browser_relay().
| #define HTTP_HEADER_CLOSED_SESSION -1997 |
Definition at line 25 of file http_tool.h.
Referenced by recv_http_header(), and www2browser_relay().
| #define HTTP_HEADER_NOT_HTTP -1990 |
Definition at line 24 of file http_tool.h.
Referenced by recv_http_header().
| #define HTTP_HEADER_UNKNOWN_LEN -1999 |
Definition at line 27 of file http_tool.h.
Referenced by recv_http_Buffer(), recv_http_file(), and recv_http_header().
| #define HTTP_LINK_METHOD 10 |
Definition at line 43 of file http_tool.h.
Referenced by get_http_method().
| #define HTTP_LOCK_METHOD 25 |
Definition at line 52 of file http_tool.h.
Referenced by get_http_method().
| #define HTTP_MKCOL_METHOD 22 |
Definition at line 49 of file http_tool.h.
Referenced by get_http_method().
| #define HTTP_MOVE_METHOD 24 |
Definition at line 51 of file http_tool.h.
Referenced by get_http_method().
| #define HTTP_OPTIONS_METHOD 5 |
Definition at line 38 of file http_tool.h.
Referenced by get_http_method().
| #define HTTP_PATCH_METHOD 9 |
Definition at line 42 of file http_tool.h.
Referenced by get_http_method().
| #define HTTP_POST_METHOD 3 |
Definition at line 36 of file http_tool.h.
Referenced by get_http_method().
| #define HTTP_PROPFIND_METHOD 20 |
Definition at line 47 of file http_tool.h.
Referenced by get_http_method().
| #define HTTP_PROPPATCH_METHOD 21 |
Definition at line 48 of file http_tool.h.
Referenced by get_http_method().
| #define HTTP_PROXY_TIMEOUT 60 |
Definition at line 59 of file http_tool.h.
Referenced by simple_web_proxy().
| #define HTTP_PUT_METHOD 2 |
Definition at line 35 of file http_tool.h.
Referenced by get_http_method().
| #define HTTP_RESPONSE_METHOD 99 |
Definition at line 55 of file http_tool.h.
Referenced by get_http_method().
| #define HTTP_RESPONSE_TIMEOUT 180 |
Definition at line 58 of file http_tool.h.
| #define HTTP_TIMEOUT 60 |
Definition at line 57 of file http_tool.h.
| #define HTTP_TRACE_METHOD 7 |
Definition at line 40 of file http_tool.h.
Referenced by get_http_method().
| #define HTTP_UNKNOWN_METHOD 0 |
Definition at line 31 of file http_tool.h.
Referenced by get_http_header_method(), get_http_method(), recv_http_Buffer(), and recv_http_header().
| #define HTTP_UNLINK_METHOD 11 |
Definition at line 44 of file http_tool.h.
Referenced by get_http_method().
| #define HTTP_UNLOCK_METHOD 26 |
Definition at line 53 of file http_tool.h.
Referenced by get_http_method().
| void dump_http_header | ( | FILE * | fp, |
| tList * | pp ) |
void dump_http_header(FILE* fp, tList* pp)
HTTPのヘッダ(pp)の内容をダンプする.
Definition at line 942 of file http_tool.c.
References FALSE, fdump(), HDLIST_CONTENTS_KEY, and TRUE.

| int get_chunked_size | ( | char * | ptr, |
| int * | hdsz, | ||
| int * | tlsz ) |
int get_chunked_size(char* ptr, int* hdsz, int* tlsz)
データの先頭のチャンクのサイズを得る. hdsz にChunkで使用されるデータのヘッダのサイズが入る. tlsz にChunkで使用されるデータのトレーラのサイズが入る.
hdsz + ck + *tlsz が全データサイズ
Definition at line 981 of file http_tool.c.
References hexstr2i(), and L_32.
Referenced by recv_http_chunked().


| char * get_http_header_date | ( | time_t | tm | ) |
Definition at line 1015 of file http_tool.c.
References buf, and get_gmt_timestamp().

| int get_http_header_method | ( | tList * | pl | ) |
int get_http_header_method(tList* pl)
ヘッダ情報の格納された plから,HTTPコマンドとパスを取り出す.
Definition at line 898 of file http_tool.c.
References Buffer::buf, get_http_method(), HDLIST_FIRST_LINE_KEY, HTTP_UNKNOWN_METHOD, and search_protocol_header().

| int get_http_method | ( | char * | data | ) |
Definition at line 837 of file http_tool.c.
References ex_strcmp, HTTP_CONNECT_METHOD, HTTP_COPY_METHOD, HTTP_DELETE_METHOD, HTTP_GET_METHOD, HTTP_HEAD_METHOD, HTTP_LINK_METHOD, HTTP_LOCK_METHOD, HTTP_MKCOL_METHOD, HTTP_MOVE_METHOD, HTTP_OPTIONS_METHOD, HTTP_PATCH_METHOD, HTTP_POST_METHOD, HTTP_PROPFIND_METHOD, HTTP_PROPPATCH_METHOD, HTTP_PUT_METHOD, HTTP_RESPONSE_METHOD, HTTP_TRACE_METHOD, HTTP_UNKNOWN_METHOD, HTTP_UNLINK_METHOD, and HTTP_UNLOCK_METHOD.
Referenced by get_http_header_method(), and recv_http_header().

| int get_http_status_num | ( | tList * | pl | ) |
Definition at line 1401 of file http_tool.c.
References Buffer::buf, cawk_Buffer(), free_Buffer(), HDLIST_FIRST_LINE_KEY, and search_protocol_header().
Referenced by recv_http_header().


| float get_http_version_num | ( | tList * | pl | ) |
Definition at line 1421 of file http_tool.c.
References buf, Buffer::buf, cawk_Buffer(), free_Buffer(), HDLIST_FIRST_LINE_KEY, and search_protocol_header().
Referenced by recv_http_header().


| Buffer http_proxy_header_analyze | ( | tList * | pl, |
| Buffer * | server, | ||
| unsigned short * | sport, | ||
| int * | timeout, | ||
| int * | keep ) |
Buffer http_proxy_header_analyze(tList* pl, Buffer* server, unsigned short* sport, int* timeout, int* keep)
ブラウザからのプロキシ用リクエストを解析する.
| pl | 解析するヘッダ情報の入ったリストへのポインタ | |
| [out] | server | 接続相手の名前またはIPアドレスが代入される |
| [out] | sport | 接続相手のポート番号が代入される. |
| [out] | timeout | ブラウザからの Keep-Alive の値が代入される. |
| [out] | keep | 接続を維持するかどうかが代入される.(TRUE:維持する/FALSE:維持しない) |
Definition at line 1164 of file http_tool.c.
References Buffer::buf, cat_Buffer(), cat_s2Buffer, cawk_Buffer(), copy_Buffer(), decomp_url(), del_tList_node(), FALSE, free_Buffer(), HDLIST_FIRST_LINE_KEY, init_Buffer(), strncasecmp_tList(), and TRUE.
Referenced by simple_web_proxy().


| int is_http_header_field | ( | tList * | pl, |
| char * | field, | ||
| char * | value, | ||
| int | n ) |
int is_http_header_field(tList* pl, char* field, char* value, int n)
HTTPのヘッダ部分で n番目の filed の値が valueなら TRUEを返し,違っていれば FALSEを返す.
| pl | ヘッダ情報が格納されるリストへのポインタ |
| field | ヘッダ中の フィールド名. |
| value | 比較するフィールドの値. |
| n | フィールドが複数あった場合は n番目のフィールドと比較する |
| TRUE | フィールドの値が一致した. |
| FALSE | フィールドの値が一致しなかった. |
Definition at line 877 of file http_tool.c.
References Buffer::buf, FALSE, free_Buffer(), search_protocol_header(), and TRUE.
Referenced by recv_http_Buffer(), recv_http_file(), and recv_http_header().


Definition at line 74 of file http_tool.c.
References buf, cat_Buffer(), copy_i2Buffer(), dup_Buffer(), FALSE, OFF, restore_protocol_header(), and TRUE.
Referenced by send_http_Buffer().


| int recv_http_Buffer | ( | int | sofd, |
| tList ** | pl, | ||
| Buffer * | buf, | ||
| int | tsecond, | ||
| int * | hdonly, | ||
| int * | state, | ||
| int | nochunk ) |
HTTPメッセージを受信して,Buffer変数 *bufに保存する.gzipのエンコード処理は行わない.
bufのバッファ領域は予め確保されていること.
| sofd | 接続相手へのソケット | |
| [out] | *pl | 受信したヘッダが格納されるリストへのポインタ.必要ないなら NULLでも良い. |
| [out] | buf | コンテンツを格納する Buffer変数へのポインタ.バッファ部は予め確保して置く. |
| tsecond | 最初の受信までのタイムアウト(s) | |
| [out] | hdonly | データがヘッダのみの場合は TRUE, コンテンツもある場合は FALSE.NULLを指定しても良い. |
| [out] | state | サーバとの接続状態.接続中なら TRUE.切断した場合は FALSE.NULLを指定しても良い. |
| nochunk | chunkデータを処理しない |
| 0以上 | 受信したコンテンツのサイズ(Byte) |
| JBXL_NET_RECV_ERROR | 受信エラー |
| JBXL_ARGS_ERROR | buf エラー |
| JBXL_NET_RECV_TIMEOUT | タイムアウトした. |
Definition at line 577 of file http_tool.c.
References add_protocol_header, buf, Buffer::buf, clear_Buffer(), copy_Buffer(), del_tList(), delete_protocol_header, FALSE, free_Buffer(), freeNull, HDLIST_CONTENTS_KEY, HTTP_HEADER_CHUNKED, HTTP_HEADER_UNKNOWN_LEN, HTTP_UNKNOWN_METHOD, is_http_header_field(), itostr_ts(), JBXL_ARGS_ERROR, len, recv_http_chunked(), recv_http_closed(), recv_http_content(), recv_http_header(), search_protocol_header(), TRUE, and Buffer::vldsz.

| int recv_http_chunked | ( | int | sofd, |
| Buffer * | buf, | ||
| int | tm, | ||
| FILE * | fp, | ||
| int * | state ) |
int recv_http_chunked(int sofd, Buffer* buf, int tm, FILE* fp, int* state)
HTTPメッセージで recv_http_header() で受信したヘッダに引き続いて,Chunkモードのコンテンツデータを受信する.
fp がNULLでなければ,受信データ(コンテンツ)はファイルにも保存される.
| sofd | 接続相手へのソケット | |
| [in,out] | buf | 全コンテンツを保存する変数.最初に,recv_https_header()で受信したコンテンツ部分を入れて置く. |
| tm | タイムアウト秒数. | |
| fp | 受信したコンテンツを保存するファイルディスクリプタ.NULLなら保存しない. | |
| [out] | state | サーバとの接続状態.接続中なら TRUE.切断した場合は FALSE.NULLを指定しても良い. |
| 0以上 | 全コンテンツのサイズ(Byte).recv_https_header()で受信したコンテンツ部分を含む. |
| 0未満 | エラー |
Definition at line 410 of file http_tool.c.
References buf, Buffer::buf, cat_Buffer(), clear_Buffer(), FALSE, free_Buffer(), get_chunked_size(), make_Buffer(), recv_http_chunked_remain(), RECVBUFSZ, tcp_recv_Buffer_wait(), TRUE, and Buffer::vldsz.
Referenced by recv_http_Buffer(), and recv_http_file().


| int recv_http_chunked_remain | ( | int | sofd, |
| Buffer * | buf, | ||
| int | chnksz, | ||
| int | tm ) |
int recv_http_chunked_remain(int sofd, Buffer* buf, int chnksz, int tm)
chunk の残りのデータを読み込む.次の chunkのデータも読み込まれる可能性がある.
| sofd | 接続相手へのソケット | |
| [in,out] | buf | 残りのコンテンツを保存する変数.最初に,recv_http_header()で受信したコンテンツ部分を入れて置く. |
| chnksz | 最低限読み込むべきサイズ.chunkのサイズ | |
| tm | タイムアウト秒数. |
| 1以上 | 読み込んだコンテンツのサイズ(Byte).recv_http_header()で受信したコンテンツ部分を含む. |
| 0以下 | エラー |
Definition at line 489 of file http_tool.c.
References buf, cat_Buffer(), free_Buffer(), make_Buffer(), RECVBUFSZ, and tcp_recv_Buffer_wait().
Referenced by recv_http_chunked().


| int recv_http_closed | ( | int | sofd, |
| Buffer * | buf, | ||
| int | tm, | ||
| FILE * | fp ) |
int recv_http_closed(int sofd, Buffer* buf, int tm, FILE* fp)
HTTPメッセージで recv_http_header() で受信したヘッダに引き続いて,長さ不明のコンテンツデータを受信する. この命令で残りの全てのヘッダを読み込む.
fp がNULLでなければ,受信データ(コンテンツ)はファイルにも保存される.
| sofd | 接続相手へのソケット | |
| [in,out] | buf | 全コンテンツを保存する変数.最初に,recv_https_header()で受信したコンテンツ部分を入れて置く. |
| tm | タイムアウト秒数. | |
| fp | 受信したコンテンツを保存するファイルディスクリプタ.NULLなら保存しない. |
| 0以上 | 全コンテンツのサイズ(Byte).recv_https_header()で受信したコンテンツ部分を含む. |
| 0未満 | エラー |
Definition at line 529 of file http_tool.c.
References buf, Buffer::buf, cat_Buffer(), free_Buffer(), JBXL_NET_RECV_TIMEOUT, make_Buffer(), recv_wait(), RECVBUFSZ, tcp_recv_Buffer(), and Buffer::vldsz.
Referenced by recv_http_Buffer(), and recv_http_file().


| int recv_http_content | ( | int | sofd, |
| Buffer * | buf, | ||
| int | len, | ||
| int | tm, | ||
| FILE * | fp, | ||
| int * | state ) |
int recv_http_content(int sofd, Buffer* buf, int len, int tm, FILE* fp, int* state)
HTTPメッセージで recv_http_header() で受信したヘッダに引き続いて,コンテンツを受信する.
fp がNULLでなければ,受信データ(コンテンツ)はファイルにも保存される.
| sofd | 接続相手へのソケット | |
| [in,out] | buf | 全コンテンツを保存する変数.最初に,recv_https_header()で受信したコンテンツ部分を入れて置く. |
| len | 受信したヘッダの "Content-Length" の値.受信データのサイズのチェックに使用する. | |
| tm | タイムアウト秒数. | |
| fp | 受信したコンテンツを保存するファイルディスクリプタ.NULLなら保存しない. | |
| [out] | state | サーバとの接続状態.接続中なら TRUE.切断した場合は FALSE.NULLを指定しても良い. |
| 0以上 | 全コンテンツのサイズ(Byte).recv_https_header()で受信したコンテンツ部分を含む. |
| 0未満 | エラー |
Definition at line 361 of file http_tool.c.
References buf, Buffer::buf, cat_Buffer(), FALSE, free_Buffer(), len, make_Buffer(), RECVBUFSZ, tcp_recv_Buffer_wait(), TRUE, and Buffer::vldsz.
Referenced by recv_http_Buffer(), recv_http_file(), and simple_web_proxy().


| int recv_http_file | ( | int | sofd, |
| tList ** | pl, | ||
| const char * | fname, | ||
| const char * | wdir, | ||
| int | tsecond, | ||
| int * | hdonly, | ||
| int * | state ) |
HTTPメッセージを受信して,コンテンツをファイルに保存する.Encodingが gzipの場合は展開する.
| sofd | 接続相手へのソケット | |
| [out] | *pl | 受信したヘッダが格納されるリストへのポインタ. |
| fname | 保存するファイル名 | |
| wdir | 作業用ディレクトリを指定.NULLの場合は /tmp になる. | |
| tsecond | 最初の受信までのタイムアウト(s) | |
| [out] | hdonly | データがヘッダのみの場合は TRUE, コンテンツもある場合は FALSE.NULLを指定しても良い. |
| [out] | state | サーバとの接続状態.接続中なら TRUE.切断した場合は FALSE.NULLを指定しても良い. |
| 1以上 | 受信したファイルのサイズ(Byte)(ヘッダを含む) |
| 0 | 正常切断 |
| JBXL_NET_RECV_ERROR | 受信エラー |
| JBXL_NET_RECV_TIMEOUT | タイムアウトした. |
Definition at line 667 of file http_tool.c.
References add_protocol_header, buf, Buffer::buf, copy_Buffer(), DEBUG_MODE, delete_protocol_header, FALSE, free_Buffer(), freeNull, gz_decode_file_replace(), HDLIST_CONTENTS_KEY, HTTP_HEADER_CHUNKED, HTTP_HEADER_UNKNOWN_LEN, is_http_header_field(), itostr_ts(), len, make_Buffer(), PRINT_MESG, recv_http_chunked(), recv_http_closed(), recv_http_content(), recv_http_header(), RECVBUFSZ, search_protocol_header(), TRUE, and Buffer::vldsz.
Referenced by save_http_xml().


| int recv_http_header | ( | int | sofd, |
| tList ** | pl, | ||
| int * | len, | ||
| int | tm, | ||
| FILE * | fp, | ||
| int * | state ) |
int recv_http_header(int sofd, tList** pl, int* len, int tm, FILE* fp, int* state)
HTTP通信のヘッダ部分を受信して,リストに格納する.
NULLでない fp が指定された場合,受信した全てのデータをファイルに保存する. 受信したデータが HTTPでない場合は,*pl の HDLIST_CONTENTS_KEY の値として受信データを格納する.
| sofd | 接続相手へのソケット | |
| [out] | *pl | ヘッダ情報が格納されるリストへのポインタ.NULLなら格納しない. (*pl)->ldat.id に HTTPデータのコマンド種別が入る.(HTTP_GET_METHOD など) |
| [out] | len | ヘッダ中の "Content-Length" の値(正の値). "Content-Length" が存在しなければ HTTP_HEADER_UNKNOWN_LEN (0未満). チャンク形式なら HTTP_HEADER_CHUNKED (0未満). 引き続く1回のセッション内でボディを転送するのなら,HTTP_HEADER_CLOSED_SESSION (0未満). 受信データが HTTP でないなら HTTP_HEADER_NOT_HTTP (0未満). |
| tm | タイムアウト秒数. | |
| fp | 受信した全てのデータを保存するためのファイルポインタ.NULLの場合は保存しない. | |
| [out] | state | サーバとの接続状態.接続中なら TRUE.切断した場合は FALSE.NULLを指定しても良い. |
| 0以上 | 受信した全バイト数 |
| 0 | 正常切断 |
| JBXL_NET_RECV_ERROR | 受信エラー |
| JBXL_ARGS_ERROR | 無効な sofdを指定した または len にNULL を指定した |
Definition at line 240 of file http_tool.c.
References add_tList_node_Buffer, Buffer::buf, FALSE, find_tList_top(), free_Buffer(), get_http_method(), get_http_status_num(), get_http_version_num(), get_protocol_header_list_seq(), HDLIST_CONTENTS_KEY, HDLIST_END_KEY, HTTP_GET_METHOD, HTTP_HEADER_CHUNKED, HTTP_HEADER_CLOSED_SESSION, HTTP_HEADER_NOT_HTTP, HTTP_HEADER_UNKNOWN_LEN, HTTP_UNKNOWN_METHOD, is_http_header_field(), JBXL_ARGS_ERROR, JBXL_NET_RECV_ERROR, len, Loop, make_Buffer(), make_Buffer_str, RECVBUFSZ, search_protocol_header(), strncasecmp_tList(), tcp_recv_Buffer_wait(), TRUE, and Buffer::vldsz.
Referenced by recv_http_Buffer(), recv_http_file(), simple_web_proxy(), and www2browser_relay().


| int save_http_xml | ( | int | cofd, |
| tList ** | pl, | ||
| tXML ** | xml, | ||
| char ** | recvfn, | ||
| const char * | wdir, | ||
| int | timeout, | ||
| int * | state ) |
受信した XML通信データをファイルに保存
| cofd | 接続相手へのソケット | |
| [out] | *pl | 受信したヘッダが格納されるリストへのポインタ. |
| [out] | *xml | パースされたデータが格納されるXML構造体へのポインタ |
| [out] | *recvfn | 保存するファイル名 |
| wdir | 作業用ディレクトリを指定する.NULLの場合は /tmp になる. | |
| timeout | 最初の受信までのタイムアウト(s) | |
| [out] | state | サーバとの接続状態.接続中なら TRUE.切断した場合は FALSE.NULLを指定しても良い. |
| 1以上 | 受信したファイルのサイズ(Byte)(ヘッダを含む) |
| 0 | 正常切断 |
| JBXL_NET_RECV_ERROR | 受信エラー |
| JBXL_NET_RECV_TIMEOUT | タイムアウトした. |
Definition at line 797 of file http_tool.c.
References buf, del_all_xml, free_Buffer(), JBXL_NET_RECV_ERROR, recv_http_file(), search_protocol_header(), temp_filename(), WORK_FILENAME_LEN, and xml_parse_file().

int send_http_Buffer(int sofd, tList* pl, Buffer* buf)
ヘッダとバッファの内容を HTTP通信で送信する.
| sofd | 接続相手へのソケット |
| pl | ファイルに先立って送信されるヘッダが格納されるリストへのポインタ. |
| buf | 送信するコンテンツが格納された Buffer変数へのポインタ. |
| 0以上 | 送信したデータの全サイズ(Byte) |
| JBXL_ARGS_ERROR | リストへのポインタが NULL |
Definition at line 116 of file http_tool.c.
References buf, free_Buffer(), rebuild_http_Buffer(), and tcp_send_Buffer().

| int send_http_file | ( | int | sofd, |
| tList * | pl, | ||
| const char * | fname ) |
int send_http_file(int sofd, tList* pp, const char* fname)
ヘッダとファイルの内容を HTTP通信で送信する.
| sofd | 接続相手へのソケット |
| pl | ファイルに先立って送信されるヘッダが格納されるリストへのポインタ. |
| fname | 送信するファイル名.ヘッダのみ送る場合は NULL |
| 0以上 | 送信したデータの全サイズ(Byte) |
| JBXL_ARGS_ERROR | リストへのポインタが NULL |
| JBXL_MALLOC_ERROR | メモリ確保エラー |
Definition at line 163 of file http_tool.c.
References buf, cat_b2Buffer(), copy_s2Buffer, file_size(), free_Buffer(), JBXL_ARGS_ERROR, JBXL_MALLOC_ERROR, OFF, restore_protocol_header(), tcp_send_Buffer(), and UNUSED.

| int send_http_header | ( | int | sofd, |
| tList * | pp, | ||
| int | mode ) |
int send_http_header(int sofd, tList* pp, int mode)
ヘッダリストの内容を HTTP通信で送信する. ヘッダ中の Content-Length の値は操作しない.
| sofd | 接続相手へのソケット |
| pp | 送信するヘッダが格納されるリストへのポインタ. |
| mode | ON: ヘッダリスト内にコンテンツの一部があればそれも送信する. |
| mode | OFF: ヘッダリスト内にコンテンツの一部があっても送信しない. |
| 0以上 | mode==OFF: 送信した全データバイト数. mode==ON : 送信したコンテンツのバイト数. |
| 0未満 | エラー |
| JBXL_ARGS_ERROR | リストへのポインタが NULL |
Definition at line 56 of file http_tool.c.
References buf, free_Buffer(), JBXL_ARGS_ERROR, ON, restore_protocol_header(), and tcp_send_Buffer().
Referenced by simple_web_proxy(), and www2browser_relay().


| void send_http_passwd_req | ( | int | sock | ) |
Definition at line 1506 of file http_tool.c.
References tcp_send().

| int send_http_res_file | ( | int | sock, |
| char * | fn, | ||
| int | mode ) |
Definition at line 1457 of file http_tool.c.
References buf, file_size(), HTTP_CONNECTION_CLOSE, JBXL_FILE_OPEN_ERROR, JBXL_MALLOC_ERROR, LBUF, tcp_send(), and UNUSED.

| void set_http_host_header | ( | tList * | pl, |
| char * | hname, | ||
| unsigned short | hport ) |
void set_http_host_header(tList* pl, const char* hname, unsigned short hport)
HTTPのヘッダ(pl)の Hostを hname:hport に書き換える. Hostヘッダが無い場合は,最後に追加.
Definition at line 917 of file http_tool.c.
References buf, cat_s2Buffer, copy_s2Buffer, free_Buffer(), LBUF, LEN_INT, make_Buffer(), ON, and set_protocol_header().

| void simple_web_proxy | ( | int | bofd, |
| char * | myip, | ||
| int | tmout ) |
void simple_web_proxy(int bofd, char* myip, int tmout)
簡易WEBプロキシ.WWW通信をリレーする.
全てのHTTPプロトコルをサポートしている訳ではない. 接続はできる限りの範囲でしか維持しない.
| bofd | ブラウザとの通信ソケット |
| myip | 自分のIPアドレス. |
| tmout | タイムアウト(sec) |
Definition at line 1044 of file http_tool.c.
References buf, Buffer::buf, del_tList(), free_Buffer(), freeNull, get_ipaddr_byname(), http_proxy_header_analyze(), HTTP_PROXY_TIMEOUT, len, make_Buffer(), make_Buffer_bystr, Min, ON, recv_http_content(), recv_http_header(), RECVBUFSZ, send_http_header(), socket_close(), tcp_client_socket, tcp_relay(), tcp_send(), tcp_send_Buffer(), TRUE, and www2browser_relay().

| int tcp_relay | ( | int | sofd, |
| int | cofd, | ||
| int | tm ) |
int tcp_relay(int sofd, int cofd, int tm)
TCP通信をリレーする.
| sofd | クライアント側ソケット |
| cofd | サーバ側ソケット |
| tm | タイムアウト時間(sec) |
| 0以上 | 転送したバイト数 |
| 0未満 | エラー |
| JBXL_NET_RECV_TIMEOUT | タイムアウト |
Definition at line 1336 of file http_tool.c.
References buf, free_Buffer(), JBXL_NET_RECV_TIMEOUT, make_Buffer(), Max, RECVBUFSZ, tcp_recv_Buffer(), and tcp_send_Buffer().
Referenced by simple_web_proxy().


| int www2browser_relay | ( | int | bofd, |
| int | wofd, | ||
| int | btm, | ||
| int | wtm, | ||
| int | keep ) |
int www2browser_relay(int bofd, int wofd, int btm, int wtm, int keep)
WWW -> Browser の通信をリレーする.
| bofd | ブラウザ側のソケット |
| wofd | WWWサーバ側のソケット |
| btm | ブラウザとのタイムアウト |
| wtm | WWWサーバとのタイムアウト |
| keep | TRUE 接続を(可能な限り)維持する |
| keep | FALSE 接続を維持しない. |
| 0未満 | エラー |
| JBXL_NET_RECV_TIMEOUT | タイムアウト |
Definition at line 1240 of file http_tool.c.
References add_tList_node_str, buf, del_tList(), free_Buffer(), HDLIST_END_KEY, HTTP_HEADER_CHUNKED, HTTP_HEADER_CLOSED_SESSION, JBXL_NET_RECV_ERROR, JBXL_NET_RECV_TIMEOUT, len, make_Buffer(), ON, recv_http_header(), recv_wait(), RECVBUFSZ, send_http_header(), strncasecmp_tList(), tcp_recv_Buffer(), and tcp_send_Buffer().
Referenced by simple_web_proxy().

