1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
| int mg_parse_http(const char *s, int n, struct http_message *hm, int is_req);
struct mg_str *mg_get_http_header(struct http_message *hm, const char *name);
int mg_http_parse_header(struct mg_str *hdr, const char *var_name, char *buf, size_t buf_size);
int mg_get_http_basic_auth(struct http_message *hm, char *user, size_t user_len, char *pass, size_t pass_len);
int mg_parse_http_basic_auth(struct mg_str *hdr, char *user, size_t user_len, char *pass, size_t pass_len);
size_t mg_parse_multipart(const char *buf, size_t buf_len, char *var_name, size_t var_name_len, char *file_name, size_t file_name_len, const char **chunk, size_t *chunk_len);
int mg_get_http_var(const struct mg_str *buf, const char *name, char *dst, size_t dst_len);
struct mg_serve_http_opts { const char *document_root; const char *index_files;
const char *per_directory_auth_file; const char *auth_domain;
const char *global_auth_file; const char *enable_directory_listing; const char *ssi_pattern; const char *ip_acl; #if MG_ENABLE_HTTP_URL_REWRITES const char *url_rewrites;/源码有详细介绍 #endif const char *dav_document_root; const char *dav_auth_file; const char *hidden_file_pattern; const char *cgi_file_pattern; const char *cgi_interpreter; const char *custom_mime_types;
const char *extra_headers; } void mg_serve_http(struct mg_connection *nc, struct http_message *hm, struct mg_serve_http_opts opts);
void mg_http_serve_file(struct mg_connection *nc, struct http_message *hm, const char *path, const struct mg_str mime_type, const struct mg_str extra_headers);
typedef struct mg_str (*mg_fu_fname_fn)(struct mg_connection *nc, struct mg_str fname); void mg_file_upload_handler(struct mg_connection *nc, int ev, void *ev_data, mg_fu_fname_fn local_name_fn MG_UD_ARG(void *user_data));
void mg_register_http_endpoint(struct mg_connection *nc, const char *uri_path, MG_CB(mg_event_handler_t handler, void *user_data));
struct mg_http_endpoint_opts { void *user_data; const char *auth_domain; const char *auth_file; }; void mg_register_http_endpoint_opt(struct mg_connection *nc, const char *uri_path, mg_event_handler_t handler, struct mg_http_endpoint_opts opts); int mg_http_check_digest_auth(struct http_message *hm, const char *auth_domain, FILE *fp);
int mg_check_digest_auth(struct mg_str method, struct mg_str uri, struct mg_str username, struct mg_str cnonce, struct mg_str response, struct mg_str qop, struct mg_str nc, struct mg_str nonce, struct mg_str auth_domain, FILE *fp);
void mg_send_http_chunk(struct mg_connection *nc, const char *buf, size_t len);
void mg_printf_http_chunk(struct mg_connection *nc, const char *fmt, ...);
void mg_send_response_line(struct mg_connection *nc, int status_code, const char *extra_headers);
void mg_http_send_error(struct mg_connection *nc, int code, const char *reason);
void mg_http_send_redirect(struct mg_connection *nc, int status_code, const struct mg_str location, const struct mg_str extra_headers);
void mg_send_head(struct mg_connection *n, int status_code, int64_t content_length, const char *extra_headers);
void mg_printf_html_escape(struct mg_connection *nc, const char *fmt, ...);
void mg_http_reverse_proxy(struct mg_connection *nc, const struct http_message *hm, struct mg_str mount, struct mg_str upstream);
|