| 1 | /* |
| 2 | * Copyright (c) 2013-2022 Joris Vink <[email protected]> |
| 3 | * |
| 4 | * Permission to use, copy, modify, and distribute this software for any |
| 5 | * purpose with or without fee is hereby granted, provided that the above |
| 6 | * copyright notice and this permission notice appear in all copies. |
| 7 | * |
| 8 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 9 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 10 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 11 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 12 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 13 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
| 14 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 15 | */ |
| 16 | |
| 17 | #include <sys/param.h> |
| 18 | #include <sys/types.h> |
| 19 | |
| 20 | #include <sys/socket.h> |
| 21 | #include <netinet/in.h> |
| 22 | |
| 23 | #include <ctype.h> |
| 24 | #include <fcntl.h> |
| 25 | #include <inttypes.h> |
| 26 | #include <float.h> |
| 27 | #include <time.h> |
| 28 | #include <stdio.h> |
| 29 | #include <string.h> |
| 30 | |
| 31 | #include "kore.h"cxx . . $ `<file>/include/kore/kore.h`/ |
| 32 | #include "http.h"cxx . . $ `<file>/include/kore/http.h`/ |
| 33 | |
| 34 | #if defined(KORE_USE_PYTHON) |
| 35 | #include "python_api.h" |
| 36 | #endif |
| 37 | |
| 38 | #if defined(KORE_USE_PGSQL) |
| 39 | #include "pgsql.h" |
| 40 | #endif |
| 41 | |
| 42 | #if defined(KORE_USE_TASKS) |
| 43 | #include "tasks.h" |
| 44 | #endif |
| 45 | |
| 46 | #if defined(KORE_USE_CURL) |
| 47 | #include "curl.h" |
| 48 | #endif |
| 49 | |
| 50 | static structcxx . . $ $anonymous_type_c1fee551f892c63c_0# { |
| 51 | const char *extcxx . . $ $anonymous_type_c1fee551f892c63c_0#ext.; |
| 52 | const char *typecxx . . $ $anonymous_type_c1fee551f892c63c_0#type.; |
| 53 | } builtin_mediacxx . . $ builtin_media.[] = { |
| 54 | { "gif", "image/gif" }, |
| 55 | { "png", "image/png" }, |
| 56 | { "jpeg", "image/jpeg" }, |
| 57 | { "jpg", "image/jpeg" }, |
| 58 | { "zip", "application/zip" }, |
| 59 | { "pdf", "application/pdf" }, |
| 60 | { "json", "application/json" }, |
| 61 | { "js", "application/javascript" }, |
| 62 | { "htm", "text/html" }, |
| 63 | { "txt", "text/plain" }, |
| 64 | { "css", "text/css" }, |
| 65 | { "html", "text/html" }, |
| 66 | { NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! }, |
| 67 | }; |
| 68 | |
| 69 | #define HTTP_MAP_LIMITcxx . . $ `src/http.c:69:9`! 127 |
| 70 | |
| 71 | /* |
| 72 | * token = 1*<any CHAR except CTLs or separators> |
| 73 | * separators = "(" | ")" | "<" | ">" | "@" |
| 74 | * | "," | ";" | ":" | "\" | <"> |
| 75 | * | "/" | "[" | "]" | "?" | "=" |
| 76 | * | "{" | "}" | SP | HT |
| 77 | */ |
| 78 | static const char http_tokencxx . . $ http_token.[] = { |
| 79 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 80 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 81 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 82 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 83 | 0x00, '!' , 0x00, '#' , '$' , '%' , '&' , '\'', |
| 84 | 0x00, 0x00, '*' , '+' , 0x00, '-' , '.' , 0x00, |
| 85 | '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , |
| 86 | '8' , '9' , 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 87 | 0x00, 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , |
| 88 | 'H' , 'I' , 'J' , 'K' , 'L' , 'M' , 'N' , 'O' , |
| 89 | 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , |
| 90 | 'X' , 'Y' , 'Z' , 0x00, 0x00, 0x00, '^' , '_' , |
| 91 | '`' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , |
| 92 | 'h' , 'i' , 'j' , 'k' , 'l' , 'm' , 'n' , 'o' , |
| 93 | 'p' , 'q' , 'r' , 's' , 't' , 'u' , 'v' , 'w' , |
| 94 | 'x' , 'y' , 'z' , 0x00, '|' , 0x00, '~' , 0x00 |
| 95 | }; |
| 96 | |
| 97 | /* |
| 98 | * field-content = <the OCTETs making up the field-value |
| 99 | * and consisting of either *TEXT or combinations |
| 100 | * of token, separators, and quoted-string> |
| 101 | */ |
| 102 | static const char http_field_contentcxx . . $ http_field_content.[] = { |
| 103 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 104 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 105 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 106 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
| 107 | ' ' , '!' , '"' , '#' , '$' , '%' , '&' , '\'', |
| 108 | '(' , ')' , '*' , '+' , ',' , '-' , '.' , '/' , |
| 109 | '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , |
| 110 | '8' , '9' , ':' , ';' , '<' , '=' , '>' , '?' , |
| 111 | '@' , 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , |
| 112 | 'H' , 'I' , 'J' , 'K' , 'L' , 'M' , 'N' , 'O' , |
| 113 | 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , |
| 114 | 'X' , 'Y' , 'Z' , '[' , '\\', ']' , '^' , '_' , |
| 115 | '`' , 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , |
| 116 | 'h' , 'i' , 'j' , 'k' , 'l' , 'm' , 'n' , 'o' , |
| 117 | 'p' , 'q' , 'r' , 's' , 't' , 'u' , 'v' , 'w' , |
| 118 | 'x' , 'y' , 'z' , '{' , '|' , '}' , '~' , 0x00 |
| 119 | }; |
| 120 | |
| 121 | /* |
| 122 | * Fixed "pretty" HTTP error HTML page. |
| 123 | */ |
| 124 | static const char *pretty_error_fmtcxx . . $ pretty_error_fmt. = |
| 125 | "<html>\n<head>\n\t<title>%d %s</title>" |
| 126 | "</head>\n<body>\n\t" |
| 127 | "<h1>%d %s</h1>\n" |
| 128 | "</body>\n</html>\n"; |
| 129 | |
| 130 | static int http_body_recvcxx . . $ http_body_recv(82c4d452dc2a871a).(struct netbufcxx . . $ netbuf# *); |
| 131 | static int http_release_buffercxx . . $ http_release_buffer(82c4d452dc2a871a).(struct netbufcxx . . $ netbuf# *); |
| 132 | static void http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(struct connectioncxx . . $ connection# *, int); |
| 133 | static int http_data_convertcxx . . $ http_data_convert(68f79bd69bedc53).(void *, void **, void *, int); |
| 134 | static void http_write_response_cookiecxx . . $ http_write_response_cookie(c4b6faa0b9983ba1).(struct http_cookiecxx . . $ http_cookie# *); |
| 135 | static int http_body_updatecxx . . $ http_body_update(eef2fffe5d7d9806).(struct http_requestcxx . . $ http_request# *, const void *, size_t); |
| 136 | static void http_argument_addcxx . . $ http_argument_add(a82b44345cf8406a).(struct http_requestcxx . . $ http_request# *, char *, char *, |
| 137 | int, int); |
| 138 | static int http_check_redirectcxx . . $ http_check_redirect(83d71fa0c26d908b).(struct http_requestcxx . . $ http_request# *, |
| 139 | struct kore_domaincxx . . $ kore_domain# *); |
| 140 | static void http_response_normalcxx . . $ http_response_normal(22e994f97d4c6aa9).(struct http_requestcxx . . $ http_request# *, |
| 141 | struct connectioncxx . . $ connection# *, int, const void *, size_t); |
| 142 | static void multipart_add_fieldcxx . . $ multipart_add_field(846663990203301b).(struct http_requestcxx . . $ http_request# *, struct kore_bufcxx . . $ kore_buf# *, |
| 143 | char *, const char *, const int); |
| 144 | static void multipart_file_addcxx . . $ multipart_file_add(3722bdda08777045).(struct http_requestcxx . . $ http_request# *, struct kore_bufcxx . . $ kore_buf# *, |
| 145 | const char *, const char *, const char *, const int); |
| 146 | static int multipart_find_datacxx . . $ multipart_find_data(30566873e75e1a09).(struct kore_bufcxx . . $ kore_buf# *, struct kore_bufcxx . . $ kore_buf# *, |
| 147 | size_t *, struct http_requestcxx . . $ http_request# *, const void *, size_t); |
| 148 | static int multipart_parse_headerscxx . . $ multipart_parse_headers(76feff133a1f576a).(struct http_requestcxx . . $ http_request# *, |
| 149 | struct kore_bufcxx . . $ kore_buf# *, struct kore_bufcxx . . $ kore_buf# *, |
| 150 | const char *, const int); |
| 151 | |
| 152 | static struct http_requestcxx . . $ http_request# *http_request_newcxx . . $ http_request_new(f7dd24d21b927557).(struct connectioncxx . . $ connection# *, |
| 153 | const char *, const char *, char *, |
| 154 | const char *); |
| 155 | |
| 156 | static struct kore_bufcxx . . $ kore_buf# *header_bufcxx . . $ header_buf.; |
| 157 | static struct kore_bufcxx . . $ kore_buf# *ckhdr_bufcxx . . $ ckhdr_buf.; |
| 158 | static char http_versioncxx . . $ http_version.[64]; |
| 159 | static u_int16_tcxx . . $ u_int16_t# http_version_lencxx . . $ http_version_len.; |
| 160 | static TAILQ_HEADcxx . . $ `<external>/2546723208511035544/queue.h:372:9`!(, http_request) http_requestscxx . . $ http_requests.; |
| 161 | static TAILQ_HEADcxx . . $ `<external>/2546723208511035544/queue.h:372:9`!(, http_request) http_requests_sleepingcxx . . $ http_requests_sleeping.; |
| 162 | static LIST_HEADcxx . . $ `<external>/2546723208511035544/queue.h:84:9`!(, http_media_type) http_media_typescxx . . $ http_media_types.; |
| 163 | static struct kore_poolcxx . . $ kore_pool# http_request_poolcxx . . $ http_request_pool.; |
| 164 | static struct kore_poolcxx . . $ kore_pool# http_cookie_poolcxx . . $ http_cookie_pool.; |
| 165 | static struct kore_poolcxx . . $ kore_pool# http_body_pathcxx . . $ http_body_path.; |
| 166 | static struct kore_poolcxx . . $ kore_pool# http_rlq_poolcxx . . $ http_rlq_pool.; |
| 167 | |
| 168 | struct kore_poolcxx . . $ kore_pool# http_header_poolcxx . . $ http_header_pool.; |
| 169 | |
| 170 | int http_pretty_errorcxx . . $ http_pretty_error. = 0; |
| 171 | u_int32_tcxx . . $ u_int32_t# http_request_countcxx . . $ http_request_count. = 0; |
| 172 | u_int32_tcxx . . $ u_int32_t# http_request_mscxx . . $ http_request_ms. = HTTP_REQUEST_MScxx . . $ `include/kore/http.h:49:9`!; |
| 173 | u_int16_tcxx . . $ u_int16_t# http_body_timeoutcxx . . $ http_body_timeout. = HTTP_BODY_TIMEOUTcxx . . $ `include/kore/http.h:55:9`!; |
| 174 | u_int32_tcxx . . $ u_int32_t# http_request_limitcxx . . $ http_request_limit. = HTTP_REQUEST_LIMITcxx . . $ `include/kore/http.h:48:9`!; |
| 175 | u_int64_tcxx . . $ u_int64_t# http_hsts_enablecxx . . $ http_hsts_enable. = HTTP_HSTS_ENABLEcxx . . $ `include/kore/http.h:35:9`!; |
| 176 | u_int16_tcxx . . $ u_int16_t# http_header_maxcxx . . $ http_header_max. = HTTP_HEADER_MAX_LENcxx . . $ `include/kore/http.h:36:9`!; |
| 177 | u_int16_tcxx . . $ u_int16_t# http_keepalive_timecxx . . $ http_keepalive_time. = HTTP_KEEPALIVE_TIMEcxx . . $ `include/kore/http.h:34:9`!; |
| 178 | u_int16_tcxx . . $ u_int16_t# http_header_timeoutcxx . . $ http_header_timeout. = HTTP_HEADER_TIMEOUTcxx . . $ `include/kore/http.h:54:9`!; |
| 179 | |
| 180 | size_t http_body_maxcxx . . $ http_body_max. = HTTP_BODY_MAX_LENcxx . . $ `include/kore/http.h:37:9`!; |
| 181 | char *http_body_disk_pathcxx . . $ http_body_disk_path. = HTTP_BODY_DISK_PATHcxx . . $ `include/kore/http.h:50:9`!; |
| 182 | u_int64_tcxx . . $ u_int64_t# http_body_disk_offloadcxx . . $ http_body_disk_offload. = HTTP_BODY_DISK_OFFLOADcxx . . $ `include/kore/http.h:51:9`!; |
| 183 | |
| 184 | void |
| 185 | http_parent_initcxx . . $ http_parent_init(49f6e7a06ebc5aa8).(void) |
| 186 | { |
| 187 | LIST_INITcxx . . $ `<external>/2546723208511035544/queue.h:101:9`!(&http_media_types); |
| 188 | } |
| 189 | |
| 190 | void |
| 191 | http_initcxx . . $ http_init(49f6e7a06ebc5aa8).(void) |
| 192 | { |
| 193 | int prealloc, l, i; |
| 194 | |
| 195 | TAILQ_INITcxx . . $ `<external>/2546723208511035544/queue.h:387:9`!(&http_requests); |
| 196 | TAILQ_INITcxx . . $ `<external>/2546723208511035544/queue.h:387:9`!(&http_requests_sleeping); |
| 197 | |
| 198 | header_bufcxx . . $ header_buf. = kore_buf_alloccxx . . $ kore_buf_alloc(ae982dcc82edde78).(HTTP_HEADER_BUFSIZEcxx . . $ `include/kore/http.h:45:9`!); |
| 199 | ckhdr_bufcxx . . $ ckhdr_buf. = kore_buf_alloccxx . . $ kore_buf_alloc(ae982dcc82edde78).(HTTP_COOKIE_BUFSIZEcxx . . $ `include/kore/http.h:46:9`!); |
| 200 | |
| 201 | if (!http_version_lencxx . . $ http_version_len.) { |
| 202 | l = snprintfcxx . . $ snprintf(ea502d73e74c754c).(http_versioncxx . . $ http_version., sizeof(http_versioncxx . . $ http_version.), |
| 203 | "server: kore (%s)\r\n", kore_versioncxx . . $ kore_version.); |
| 204 | if (l == -1 || (size_t)l >= sizeof(http_versioncxx . . $ http_version.)) |
| 205 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("http_init(): http_version buffer too small"); |
| 206 | |
| 207 | http_version_lencxx . . $ http_version_len. = l; |
| 208 | } |
| 209 | |
| 210 | prealloc = MINcxx . . $ `<external>/1231830743887005719/param.h:102:9`!((worker_max_connections / 10), 1000); |
| 211 | kore_pool_initcxx . . $ kore_pool_init(19b74537ff42c712).(&http_request_poolcxx . . $ http_request_pool., "http_request_pool", |
| 212 | sizeof(struct http_requestcxx . . $ http_request#), http_request_limitcxx . . $ http_request_limit.); |
| 213 | kore_pool_initcxx . . $ kore_pool_init(19b74537ff42c712).(&http_header_poolcxx . . $ http_header_pool., "http_header_pool", |
| 214 | sizeof(struct http_headercxx . . $ http_header#), prealloc * HTTP_REQ_HEADER_MAXcxx . . $ `include/kore/http.h:41:9`!); |
| 215 | kore_pool_initcxx . . $ kore_pool_init(19b74537ff42c712).(&http_cookie_poolcxx . . $ http_cookie_pool., "http_cookie_pool", |
| 216 | sizeof(struct http_cookiecxx . . $ http_cookie#), prealloc * HTTP_MAX_COOKIEScxx . . $ `include/kore/http.h:43:9`!); |
| 217 | kore_pool_initcxx . . $ kore_pool_init(19b74537ff42c712).(&http_rlq_poolcxx . . $ http_rlq_pool., "http_rlq_pool", |
| 218 | sizeof(struct http_runlock_queuecxx . . $ http_runlock_queue#), http_request_limitcxx . . $ http_request_limit.); |
| 219 | |
| 220 | kore_pool_initcxx . . $ kore_pool_init(19b74537ff42c712).(&http_body_pathcxx . . $ http_body_path., |
| 221 | "http_body_path", HTTP_BODY_PATH_MAXcxx . . $ `include/kore/http.h:52:9`!, prealloc); |
| 222 | |
| 223 | for (i = 0; builtin_mediacxx . . $ builtin_media.[i].extcxx . . $ $anonymous_type_c1fee551f892c63c_0#ext. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; i++) { |
| 224 | if (!http_media_registercxx . . $ http_media_register(5ae29d726ae57f88).(builtin_mediacxx . . $ builtin_media.[i].extcxx . . $ $anonymous_type_c1fee551f892c63c_0#ext., |
| 225 | builtin_mediacxx . . $ builtin_media.[i].typecxx . . $ $anonymous_type_c1fee551f892c63c_0#type.)) { |
| 226 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("duplicate media type for %s", |
| 227 | builtin_mediacxx . . $ builtin_media.[i].extcxx . . $ $anonymous_type_c1fee551f892c63c_0#ext.); |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | |
| 232 | void |
| 233 | http_cleanupcxx . . $ http_cleanup(49f6e7a06ebc5aa8).(void) |
| 234 | { |
| 235 | if (header_bufcxx . . $ header_buf. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 236 | kore_buf_freecxx . . $ kore_buf_free(2648f45d13d14762).(header_bufcxx . . $ header_buf.); |
| 237 | header_bufcxx . . $ header_buf. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 238 | } |
| 239 | |
| 240 | if (ckhdr_bufcxx . . $ ckhdr_buf. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 241 | kore_buf_freecxx . . $ kore_buf_free(2648f45d13d14762).(ckhdr_bufcxx . . $ ckhdr_buf.); |
| 242 | ckhdr_bufcxx . . $ ckhdr_buf. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 243 | } |
| 244 | |
| 245 | kore_pool_cleanupcxx . . $ kore_pool_cleanup(68cee620b8bd445e).(&http_request_poolcxx . . $ http_request_pool.); |
| 246 | kore_pool_cleanupcxx . . $ kore_pool_cleanup(68cee620b8bd445e).(&http_header_poolcxx . . $ http_header_pool.); |
| 247 | kore_pool_cleanupcxx . . $ kore_pool_cleanup(68cee620b8bd445e).(&http_body_pathcxx . . $ http_body_path.); |
| 248 | } |
| 249 | |
| 250 | void |
| 251 | http_server_versioncxx . . $ http_server_version(85c52e162fed56f9).(const char *version) |
| 252 | { |
| 253 | int l; |
| 254 | |
| 255 | l = snprintfcxx . . $ snprintf(ea502d73e74c754c).(http_versioncxx . . $ http_version., sizeof(http_versioncxx . . $ http_version.), |
| 256 | "server: %s\r\n", version); |
| 257 | if (l == -1 || (size_t)l >= sizeof(http_versioncxx . . $ http_version.)) |
| 258 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("http_server_version(): http_version buffer too small"); |
| 259 | |
| 260 | http_version_lencxx . . $ http_version_len. = l; |
| 261 | } |
| 262 | |
| 263 | int |
| 264 | http_check_timeoutcxx . . $ http_check_timeout(3ccd8369e867b578).(struct connectioncxx . . $ connection# *c, u_int64_tcxx . . $ u_int64_t# now) |
| 265 | { |
| 266 | u_int64_tcxx . . $ u_int64_t# d; |
| 267 | |
| 268 | if (c->http_timeoutcxx . . $ connection#http_timeout. == 0) |
| 269 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 270 | |
| 271 | if (now > c->http_startcxx . . $ connection#http_start.) |
| 272 | d = now - c->http_startcxx . . $ connection#http_start.; |
| 273 | else |
| 274 | d = 0; |
| 275 | |
| 276 | if (d >= c->http_timeoutcxx . . $ connection#http_timeout.) { |
| 277 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_REQUEST_TIMEOUTcxx . . $ HTTP_STATUS_REQUEST_TIMEOUT.); |
| 278 | kore_connection_disconnectcxx . . $ kore_connection_disconnect(8475afdb72fd1ebb).(c); |
| 279 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 280 | } |
| 281 | |
| 282 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 283 | } |
| 284 | |
| 285 | void |
| 286 | http_request_sleepcxx . . $ http_request_sleep(322c51a23f687f95).(struct http_requestcxx . . $ http_request# *req) |
| 287 | { |
| 288 | if (!(req->flagscxx . . $ http_request#flags. & HTTP_REQUEST_SLEEPINGcxx . . $ `include/kore/http.h:243:9`!)) { |
| 289 | req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_SLEEPINGcxx . . $ `include/kore/http.h:243:9`!; |
| 290 | TAILQ_REMOVEcxx . . $ `<external>/2546723208511035544/queue.h:426:9`!(&http_requests, req, list); |
| 291 | TAILQ_INSERT_TAILcxx . . $ `<external>/2546723208511035544/queue.h:402:9`!(&http_requests_sleeping, req, list); |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | void |
| 296 | http_request_wakeupcxx . . $ http_request_wakeup(322c51a23f687f95).(struct http_requestcxx . . $ http_request# *req) |
| 297 | { |
| 298 | if (req->flagscxx . . $ http_request#flags. & HTTP_REQUEST_SLEEPINGcxx . . $ `include/kore/http.h:243:9`!) { |
| 299 | req->flagscxx . . $ http_request#flags. &= ~HTTP_REQUEST_SLEEPINGcxx . . $ `include/kore/http.h:243:9`!; |
| 300 | TAILQ_REMOVEcxx . . $ `<external>/2546723208511035544/queue.h:426:9`!(&http_requests_sleeping, req, list); |
| 301 | TAILQ_INSERT_TAILcxx . . $ `<external>/2546723208511035544/queue.h:402:9`!(&http_requests, req, list); |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | void |
| 306 | http_processcxx . . $ http_process(49f6e7a06ebc5aa8).(void) |
| 307 | { |
| 308 | u_int64_tcxx . . $ u_int64_t# total; |
| 309 | struct http_requestcxx . . $ http_request# *req, *next; |
| 310 | |
| 311 | total = 0; |
| 312 | |
| 313 | for (req = TAILQ_FIRSTcxx . . $ `<external>/2546723208511035544/queue.h:458:9`!(&http_requests); req != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; req = next) { |
| 314 | if (total >= http_request_mscxx . . $ http_request_ms.) |
| 315 | break; |
| 316 | |
| 317 | next = TAILQ_NEXTcxx . . $ `<external>/2546723208511035544/queue.h:459:9`!(req, list); |
| 318 | if (req->flagscxx . . $ http_request#flags. & HTTP_REQUEST_DELETEcxx . . $ `include/kore/http.h:242:9`!) { |
| 319 | http_request_freecxx . . $ http_request_free(322c51a23f687f95).(req); |
| 320 | continue; |
| 321 | } |
| 322 | |
| 323 | /* Sleeping requests should be in http_requests_sleeping. */ |
| 324 | if (req->flagscxx . . $ http_request#flags. & HTTP_REQUEST_SLEEPINGcxx . . $ `include/kore/http.h:243:9`!) |
| 325 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("http_process: sleeping request on list"); |
| 326 | |
| 327 | if (!(req->flagscxx . . $ http_request#flags. & HTTP_REQUEST_COMPLETEcxx . . $ `include/kore/http.h:241:9`!)) |
| 328 | continue; |
| 329 | |
| 330 | http_process_requestcxx . . $ http_process_request(322c51a23f687f95).(req); |
| 331 | total += req->mscxx . . $ http_request#ms.; |
| 332 | |
| 333 | if (req->flagscxx . . $ http_request#flags. & HTTP_REQUEST_DELETEcxx . . $ `include/kore/http.h:242:9`!) |
| 334 | http_request_freecxx . . $ http_request_free(322c51a23f687f95).(req); |
| 335 | } |
| 336 | } |
| 337 | |
| 338 | void |
| 339 | http_process_requestcxx . . $ http_process_request(322c51a23f687f95).(struct http_requestcxx . . $ http_request# *req) |
| 340 | { |
| 341 | int r; |
| 342 | |
| 343 | if (req->flagscxx . . $ http_request#flags. & HTTP_REQUEST_DELETEcxx . . $ `include/kore/http.h:242:9`! || req->rtcxx . . $ http_request#rt. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 344 | return; |
| 345 | |
| 346 | req->startcxx . . $ http_request#start. = kore_time_mscxx . . $ kore_time_ms(f708dce9a8856c70).(); |
| 347 | if (req->rtcxx . . $ http_request#rt.->authcxx . . $ kore_route#auth. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && !(req->flagscxx . . $ http_request#flags. & HTTP_REQUEST_AUTHEDcxx . . $ `include/kore/http.h:247:9`!)) |
| 348 | r = kore_auth_runcxx . . $ kore_auth_run(117534b4248efb65).(req, req->rtcxx . . $ http_request#rt.->authcxx . . $ kore_route#auth.); |
| 349 | else |
| 350 | r = KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!; |
| 351 | |
| 352 | switch (r) { |
| 353 | case KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!: |
| 354 | r = kore_runtime_http_requestcxx . . $ kore_runtime_http_request(2cad211aba5d4032).(req->rtcxx . . $ http_request#rt.->rcallcxx . . $ kore_route#rcall., req); |
| 355 | break; |
| 356 | case KORE_RESULT_RETRYcxx . . $ `include/kore/kore.h:89:9`!: |
| 357 | break; |
| 358 | case KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!: |
| 359 | /* |
| 360 | * Set r to KORE_RESULT_OK so we can properly |
| 361 | * flush the result from kore_auth_run(). |
| 362 | */ |
| 363 | r = KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!; |
| 364 | break; |
| 365 | default: |
| 366 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("kore_auth() returned unknown %d", r); |
| 367 | } |
| 368 | req->endcxx . . $ http_request#end. = kore_time_mscxx . . $ kore_time_ms(f708dce9a8856c70).(); |
| 369 | req->mscxx . . $ http_request#ms. = req->endcxx . . $ http_request#end. - req->startcxx . . $ http_request#start.; |
| 370 | req->totalcxx . . $ http_request#total. += req->mscxx . . $ http_request#ms.; |
| 371 | |
| 372 | switch (r) { |
| 373 | case KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!: |
| 374 | r = net_send_flushcxx . . $ net_send_flush(d3ce87d3c6fa6963).(req->ownercxx . . $ http_request#owner.); |
| 375 | if (r == KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!) |
| 376 | kore_connection_disconnectcxx . . $ kore_connection_disconnect(8475afdb72fd1ebb).(req->ownercxx . . $ http_request#owner.); |
| 377 | break; |
| 378 | case KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!: |
| 379 | kore_connection_disconnectcxx . . $ kore_connection_disconnect(8475afdb72fd1ebb).(req->ownercxx . . $ http_request#owner.); |
| 380 | break; |
| 381 | case KORE_RESULT_RETRYcxx . . $ `include/kore/kore.h:89:9`!: |
| 382 | return; |
| 383 | default: |
| 384 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("A page handler returned an unknown result: %d", r); |
| 385 | } |
| 386 | |
| 387 | if (req->rtcxx . . $ http_request#rt.->domcxx . . $ kore_route#dom.->accesslogcxx . . $ kore_domain#accesslog.) |
| 388 | kore_accesslogcxx . . $ kore_accesslog(322c51a23f687f95).(req); |
| 389 | |
| 390 | req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_DELETEcxx . . $ `include/kore/http.h:242:9`!; |
| 391 | } |
| 392 | |
| 393 | void |
| 394 | http_response_headercxx . . $ http_response_header(84119343264ef6a5).(struct http_requestcxx . . $ http_request# *req, |
| 395 | const char *header, const char *value) |
| 396 | { |
| 397 | struct http_headercxx . . $ http_header# *hdr; |
| 398 | |
| 399 | hdr = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 400 | |
| 401 | TAILQ_FOREACHcxx . . $ `<external>/2546723208511035544/queue.h:435:9`!(hdr, &req->resp_headers, list) { |
| 402 | if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(hdr->headercxx . . $ http_header#header., header)) { |
| 403 | TAILQ_REMOVEcxx . . $ `<external>/2546723208511035544/queue.h:426:9`!(&req->resp_headers, hdr, list); |
| 404 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(hdr->headercxx . . $ http_header#header.); |
| 405 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(hdr->valuecxx . . $ http_header#value.); |
| 406 | break; |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | if (hdr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 411 | hdr = kore_pool_getcxx . . $ kore_pool_get(f5c578167d321b17).(&http_header_poolcxx . . $ http_header_pool.); |
| 412 | |
| 413 | hdr->headercxx . . $ http_header#header. = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(header); |
| 414 | hdr->valuecxx . . $ http_header#value. = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(value); |
| 415 | |
| 416 | TAILQ_INSERT_TAILcxx . . $ `<external>/2546723208511035544/queue.h:402:9`!(&(req->resp_headers), hdr, list); |
| 417 | } |
| 418 | |
| 419 | void |
| 420 | http_request_freecxx . . $ http_request_free(322c51a23f687f95).(struct http_requestcxx . . $ http_request# *req) |
| 421 | { |
| 422 | #if defined(KORE_USE_TASKS) |
| 423 | struct kore_task *t, *nt; |
| 424 | int pending_tasks; |
| 425 | #endif |
| 426 | #if defined(KORE_USE_PGSQL) |
| 427 | struct kore_pgsql *pgsql; |
| 428 | #endif |
| 429 | #if defined(KORE_USE_CURL) |
| 430 | struct kore_curl *client; |
| 431 | #endif |
| 432 | struct http_filecxx . . $ http_file# *f, *fnext; |
| 433 | struct http_argcxx . . $ http_arg# *q, *qnext; |
| 434 | struct http_headercxx . . $ http_header# *hdr, *next; |
| 435 | struct http_cookiecxx . . $ http_cookie# *ck, *cknext; |
| 436 | |
| 437 | if (req->rtcxx . . $ http_request#rt. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && req->rtcxx . . $ http_request#rt.->on_freecxx . . $ kore_route#on_free. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 438 | kore_runtime_http_request_freecxx . . $ kore_runtime_http_request_free(b2fab79a8cd0cb0d).(req->rtcxx . . $ http_request#rt.->on_freecxx . . $ kore_route#on_free., req); |
| 439 | |
| 440 | if (req->runlockcxx . . $ http_request#runlock. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 441 | LIST_REMOVEcxx . . $ `<external>/2546723208511035544/queue.h:127:9`!(req->runlock, list); |
| 442 | req->runlockcxx . . $ http_request#runlock. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 443 | } |
| 444 | |
| 445 | #if defined(KORE_USE_TASKS) |
| 446 | pending_tasks = 0; |
| 447 | for (t = LIST_FIRST(&(req->tasks)); t != NULL; t = nt) { |
| 448 | nt = LIST_NEXT(t, rlist); |
| 449 | if (!kore_task_finished(t)) { |
| 450 | pending_tasks++; |
| 451 | } else { |
| 452 | kore_task_destroy(t); |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | if (pending_tasks) |
| 457 | return; |
| 458 | #endif |
| 459 | |
| 460 | #if defined(KORE_USE_PYTHON) |
| 461 | if (req->py_coro != NULL) { |
| 462 | kore_python_coro_delete(req->py_coro); |
| 463 | req->py_coro = NULL; |
| 464 | } |
| 465 | if (req->py_validator != NULL) { |
| 466 | kore_python_coro_delete(req->py_validator); |
| 467 | req->py_validator = NULL; |
| 468 | } |
| 469 | Py_XDECREF(req->py_req); |
| 470 | #endif |
| 471 | #if defined(KORE_USE_PGSQL) |
| 472 | while (!LIST_EMPTY(&(req->pgsqls))) { |
| 473 | pgsql = LIST_FIRST(&(req->pgsqls)); |
| 474 | kore_pgsql_cleanup(pgsql); |
| 475 | } |
| 476 | #endif |
| 477 | #if defined(KORE_USE_CURL) |
| 478 | while (!LIST_EMPTY(&req->chandles)) { |
| 479 | client = LIST_FIRST(&req->chandles); |
| 480 | kore_curl_cleanup(client); |
| 481 | } |
| 482 | #endif |
| 483 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(req->headerscxx . . $ http_request#headers.); |
| 484 | |
| 485 | req->hostcxx . . $ http_request#host. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 486 | req->pathcxx . . $ http_request#path. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 487 | req->headerscxx . . $ http_request#headers. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 488 | |
| 489 | TAILQ_REMOVEcxx . . $ `<external>/2546723208511035544/queue.h:426:9`!(&http_requests, req, list); |
| 490 | if (req->ownercxx . . $ http_request#owner. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 491 | TAILQ_REMOVEcxx . . $ `<external>/2546723208511035544/queue.h:426:9`!(&(req->owner->http_requests), req, olist); |
| 492 | |
| 493 | for (hdr = TAILQ_FIRSTcxx . . $ `<external>/2546723208511035544/queue.h:458:9`!(&(req->resp_headers)); hdr != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; hdr = next) { |
| 494 | next = TAILQ_NEXTcxx . . $ `<external>/2546723208511035544/queue.h:459:9`!(hdr, list); |
| 495 | TAILQ_REMOVEcxx . . $ `<external>/2546723208511035544/queue.h:426:9`!(&(req->resp_headers), hdr, list); |
| 496 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(hdr->headercxx . . $ http_header#header.); |
| 497 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(hdr->valuecxx . . $ http_header#value.); |
| 498 | kore_pool_putcxx . . $ kore_pool_put(d9a47b307a51c9d5).(&http_header_poolcxx . . $ http_header_pool., hdr); |
| 499 | } |
| 500 | |
| 501 | for (hdr = TAILQ_FIRSTcxx . . $ `<external>/2546723208511035544/queue.h:458:9`!(&(req->req_headers)); hdr != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; hdr = next) { |
| 502 | next = TAILQ_NEXTcxx . . $ `<external>/2546723208511035544/queue.h:459:9`!(hdr, list); |
| 503 | TAILQ_REMOVEcxx . . $ `<external>/2546723208511035544/queue.h:426:9`!(&(req->req_headers), hdr, list); |
| 504 | kore_pool_putcxx . . $ kore_pool_put(d9a47b307a51c9d5).(&http_header_poolcxx . . $ http_header_pool., hdr); |
| 505 | } |
| 506 | |
| 507 | for (ck = TAILQ_FIRSTcxx . . $ `<external>/2546723208511035544/queue.h:458:9`!(&(req->resp_cookies)); ck != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; ck = cknext) { |
| 508 | cknext = TAILQ_NEXTcxx . . $ `<external>/2546723208511035544/queue.h:459:9`!(ck, list); |
| 509 | TAILQ_REMOVEcxx . . $ `<external>/2546723208511035544/queue.h:426:9`!(&(req->resp_cookies), ck, list); |
| 510 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(ck->namecxx . . $ http_cookie#name.); |
| 511 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(ck->valuecxx . . $ http_cookie#value.); |
| 512 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(ck->pathcxx . . $ http_cookie#path.); |
| 513 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(ck->domaincxx . . $ http_cookie#domain.); |
| 514 | kore_pool_putcxx . . $ kore_pool_put(d9a47b307a51c9d5).(&http_cookie_poolcxx . . $ http_cookie_pool., ck); |
| 515 | } |
| 516 | |
| 517 | for (ck = TAILQ_FIRSTcxx . . $ `<external>/2546723208511035544/queue.h:458:9`!(&(req->req_cookies)); ck != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; ck = cknext) { |
| 518 | cknext = TAILQ_NEXTcxx . . $ `<external>/2546723208511035544/queue.h:459:9`!(ck, list); |
| 519 | TAILQ_REMOVEcxx . . $ `<external>/2546723208511035544/queue.h:426:9`!(&(req->req_cookies), ck, list); |
| 520 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(ck->namecxx . . $ http_cookie#name.); |
| 521 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(ck->valuecxx . . $ http_cookie#value.); |
| 522 | kore_pool_putcxx . . $ kore_pool_put(d9a47b307a51c9d5).(&http_cookie_poolcxx . . $ http_cookie_pool., ck); |
| 523 | } |
| 524 | |
| 525 | for (q = TAILQ_FIRSTcxx . . $ `<external>/2546723208511035544/queue.h:458:9`!(&(req->arguments)); q != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; q = qnext) { |
| 526 | qnext = TAILQ_NEXTcxx . . $ `<external>/2546723208511035544/queue.h:459:9`!(q, list); |
| 527 | TAILQ_REMOVEcxx . . $ `<external>/2546723208511035544/queue.h:426:9`!(&(req->arguments), q, list); |
| 528 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(q->namecxx . . $ http_arg#name.); |
| 529 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(q->s_valuecxx . . $ http_arg#s_value.); |
| 530 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(q); |
| 531 | } |
| 532 | |
| 533 | for (f = TAILQ_FIRSTcxx . . $ `<external>/2546723208511035544/queue.h:458:9`!(&(req->files)); f != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; f = fnext) { |
| 534 | fnext = TAILQ_NEXTcxx . . $ `<external>/2546723208511035544/queue.h:459:9`!(f, list); |
| 535 | TAILQ_REMOVEcxx . . $ `<external>/2546723208511035544/queue.h:426:9`!(&(req->files), f, list); |
| 536 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(f->filenamecxx . . $ http_file#filename.); |
| 537 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(f->namecxx . . $ http_file#name.); |
| 538 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(f); |
| 539 | } |
| 540 | |
| 541 | if (req->http_bodycxx . . $ http_request#http_body. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 542 | kore_buf_freecxx . . $ kore_buf_free(2648f45d13d14762).(req->http_bodycxx . . $ http_request#http_body.); |
| 543 | |
| 544 | if (req->http_body_fdcxx . . $ http_request#http_body_fd. != -1) |
| 545 | (void)closecxx . . $ close(7864480464b09eea).(req->http_body_fdcxx . . $ http_request#http_body_fd.); |
| 546 | |
| 547 | if (req->http_body_pathcxx . . $ http_request#http_body_path. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 548 | if (unlinkcxx . . $ unlink(5c4306d8553b3696).(req->http_body_pathcxx . . $ http_request#http_body_path.) == -1 && errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != ENOENTcxx . . $ `<external>/8987895939074593727/errno-base.h:6:9`!) { |
| 549 | kore_logcxx . . $ kore_log(afcfcee7634adf7d).(LOG_NOTICEcxx . . $ `<external>/6168640806541382331/syslog.h:56:9`!, "failed to unlink %s: %s", |
| 550 | req->http_body_pathcxx . . $ http_request#http_body_path., errno_scxx . . $ `include/kore/kore.h:100:9`!); |
| 551 | } |
| 552 | kore_pool_putcxx . . $ kore_pool_put(d9a47b307a51c9d5).(&http_body_pathcxx . . $ http_body_path., req->http_body_pathcxx . . $ http_request#http_body_path.); |
| 553 | } |
| 554 | |
| 555 | if (req->hdlr_extracxx . . $ http_request#hdlr_extra. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && |
| 556 | !(req->flagscxx . . $ http_request#flags. & HTTP_REQUEST_RETAIN_EXTRAcxx . . $ `include/kore/http.h:245:9`!)) |
| 557 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(req->hdlr_extracxx . . $ http_request#hdlr_extra.); |
| 558 | |
| 559 | kore_pool_putcxx . . $ kore_pool_put(d9a47b307a51c9d5).(&http_request_poolcxx . . $ http_request_pool., req); |
| 560 | http_request_countcxx . . $ http_request_count.--; |
| 561 | } |
| 562 | |
| 563 | void |
| 564 | http_serveablecxx . . $ http_serveable(37f41a81312cc3d8).(struct http_requestcxx . . $ http_request# *req, const void *data, size_t len, |
| 565 | const char *etag, const char *type) |
| 566 | { |
| 567 | const char *match; |
| 568 | |
| 569 | if (req->methodcxx . . $ http_request#method. != HTTP_METHOD_GETcxx . . $ `include/kore/http.h:229:9`!) { |
| 570 | http_response_headercxx . . $ http_response_header(84119343264ef6a5).(req, "allow", "get"); |
| 571 | http_responsecxx . . $ http_response(8f2daeb0fc6e2740).(req, HTTP_STATUS_BAD_REQUESTcxx . . $ HTTP_STATUS_BAD_REQUEST., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0); |
| 572 | return; |
| 573 | } |
| 574 | |
| 575 | if (http_request_headercxx . . $ http_request_header(8b4805cea1886632).(req, "if-none-match", &match)) { |
| 576 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(match, etag)) { |
| 577 | http_responsecxx . . $ http_response(8f2daeb0fc6e2740).(req, HTTP_STATUS_NOT_MODIFIEDcxx . . $ HTTP_STATUS_NOT_MODIFIED., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0); |
| 578 | return; |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | http_response_headercxx . . $ http_response_header(84119343264ef6a5).(req, "etag", etag); |
| 583 | http_response_headercxx . . $ http_response_header(84119343264ef6a5).(req, "content-type", type); |
| 584 | http_responsecxx . . $ http_response(8f2daeb0fc6e2740).(req, HTTP_STATUS_OKcxx . . $ HTTP_STATUS_OK., data, len); |
| 585 | } |
| 586 | |
| 587 | void |
| 588 | http_responsecxx . . $ http_response(8f2daeb0fc6e2740).(struct http_requestcxx . . $ http_request# *req, int code, const void *d, size_t l) |
| 589 | { |
| 590 | if (req->ownercxx . . $ http_request#owner. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 591 | return; |
| 592 | |
| 593 | req->statuscxx . . $ http_request#status. = code; |
| 594 | |
| 595 | switch (req->ownercxx . . $ http_request#owner.->protocxx . . $ connection#proto.) { |
| 596 | case CONN_PROTO_HTTPcxx . . $ `include/kore/kore.h:182:9`!: |
| 597 | case CONN_PROTO_WEBSOCKETcxx . . $ `include/kore/kore.h:183:9`!: |
| 598 | http_response_normalcxx . . $ http_response_normal(22e994f97d4c6aa9).(req, req->ownercxx . . $ http_request#owner., code, d, l); |
| 599 | break; |
| 600 | default: |
| 601 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("%s: bad proto %d", __func__, req->ownercxx . . $ http_request#owner.->protocxx . . $ connection#proto.); |
| 602 | /* NOTREACHED. */ |
| 603 | } |
| 604 | } |
| 605 | |
| 606 | void |
| 607 | http_response_closecxx . . $ http_response_close(8f2daeb0fc6e2740).(struct http_requestcxx . . $ http_request# *req, int code, const void *d, size_t l) |
| 608 | { |
| 609 | if (req->ownercxx . . $ http_request#owner. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 610 | return; |
| 611 | |
| 612 | req->statuscxx . . $ http_request#status. = code; |
| 613 | req->ownercxx . . $ http_request#owner.->flagscxx . . $ connection#flags. |= CONN_CLOSE_EMPTYcxx . . $ `include/kore/kore.h:192:9`!; |
| 614 | |
| 615 | switch (req->ownercxx . . $ http_request#owner.->protocxx . . $ connection#proto.) { |
| 616 | case CONN_PROTO_HTTPcxx . . $ `include/kore/kore.h:182:9`!: |
| 617 | case CONN_PROTO_WEBSOCKETcxx . . $ `include/kore/kore.h:183:9`!: |
| 618 | http_response_normalcxx . . $ http_response_normal(22e994f97d4c6aa9).(req, req->ownercxx . . $ http_request#owner., code, d, l); |
| 619 | break; |
| 620 | default: |
| 621 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("%s: bad proto %d", __func__, req->ownercxx . . $ http_request#owner.->protocxx . . $ connection#proto.); |
| 622 | /* NOTREACHED. */ |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | void |
| 627 | http_response_jsoncxx . . $ http_response_json(2a472c30726bc432).(struct http_requestcxx . . $ http_request# *req, int status, |
| 628 | struct kore_json_itemcxx . . $ kore_json_item# *json) |
| 629 | { |
| 630 | struct kore_bufcxx . . $ kore_buf# *buf; |
| 631 | |
| 632 | if (req->ownercxx . . $ http_request#owner. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 633 | return; |
| 634 | |
| 635 | buf = kore_buf_alloccxx . . $ kore_buf_alloc(ae982dcc82edde78).(1024); |
| 636 | kore_json_item_tobufcxx . . $ kore_json_item_tobuf(c5a4e1056fa52bf0).(json, buf); |
| 637 | kore_json_item_freecxx . . $ kore_json_item_free(3a9ca108fc1493c6).(json); |
| 638 | |
| 639 | req->statuscxx . . $ http_request#status. = status; |
| 640 | http_response_headercxx . . $ http_response_header(84119343264ef6a5).(req, "content-type", "application/json"); |
| 641 | |
| 642 | switch (req->ownercxx . . $ http_request#owner.->protocxx . . $ connection#proto.) { |
| 643 | case CONN_PROTO_HTTPcxx . . $ `include/kore/kore.h:182:9`!: |
| 644 | http_response_streamcxx . . $ http_response_stream(2513408f92ea4c46).(req, status, buf->datacxx . . $ kore_buf#data., buf->offsetcxx . . $ kore_buf#offset., |
| 645 | http_release_buffercxx . . $ http_release_buffer(82c4d452dc2a871a)., buf); |
| 646 | break; |
| 647 | default: |
| 648 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("%s: bad proto %d", __func__, req->ownercxx . . $ http_request#owner.->protocxx . . $ connection#proto.); |
| 649 | /* NOTREACHED. */ |
| 650 | } |
| 651 | } |
| 652 | |
| 653 | void |
| 654 | http_response_streamcxx . . $ http_response_stream(2513408f92ea4c46).(struct http_requestcxx . . $ http_request# *req, int status, void *base, |
| 655 | size_t len, int (*cb)(struct netbufcxx . . $ netbuf# *), void *arg) |
| 656 | { |
| 657 | struct netbufcxx . . $ netbuf# *nb; |
| 658 | |
| 659 | if (req->ownercxx . . $ http_request#owner. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 660 | return; |
| 661 | |
| 662 | req->statuscxx . . $ http_request#status. = status; |
| 663 | |
| 664 | switch (req->ownercxx . . $ http_request#owner.->protocxx . . $ connection#proto.) { |
| 665 | case CONN_PROTO_HTTPcxx . . $ `include/kore/kore.h:182:9`!: |
| 666 | http_response_normalcxx . . $ http_response_normal(22e994f97d4c6aa9).(req, req->ownercxx . . $ http_request#owner., status, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, len); |
| 667 | break; |
| 668 | default: |
| 669 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("%s: bad proto %d", __func__, req->ownercxx . . $ http_request#owner.->protocxx . . $ connection#proto.); |
| 670 | /* NOTREACHED. */ |
| 671 | } |
| 672 | |
| 673 | net_send_streamcxx . . $ net_send_stream(d6d8aac503cfaaf3).(req->ownercxx . . $ http_request#owner., base, len, cb, &nb); |
| 674 | nb->extracxx . . $ netbuf#extra. = arg; |
| 675 | |
| 676 | if (req->methodcxx . . $ http_request#method. == HTTP_METHOD_HEADcxx . . $ `include/kore/http.h:233:9`!) { |
| 677 | nb->s_offcxx . . $ netbuf#s_off. = nb->b_lencxx . . $ netbuf#b_len.; |
| 678 | net_remove_netbufcxx . . $ net_remove_netbuf(59f25c31eed43fe1).(req->ownercxx . . $ http_request#owner., nb); |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | void |
| 683 | http_response_filerefcxx . . $ http_response_fileref(9cb985659cc45a4c).(struct http_requestcxx . . $ http_request# *req, int status, |
| 684 | struct kore_filerefcxx . . $ kore_fileref# *ref) |
| 685 | { |
| 686 | struct tmcxx . . $ tm# *tm; |
| 687 | time_tcxx . . $ time_t# mtime; |
| 688 | char tbuf[128]; |
| 689 | const char *media_type, *modified; |
| 690 | |
| 691 | if (req->ownercxx . . $ http_request#owner. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 692 | return; |
| 693 | |
| 694 | media_type = http_media_typecxx . . $ http_media_type(fb58d2e09a2a1ce6).(ref->pathcxx . . $ kore_fileref#path.); |
| 695 | if (media_type != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 696 | http_response_headercxx . . $ http_response_header(84119343264ef6a5).(req, "content-type", media_type); |
| 697 | |
| 698 | if (http_request_headercxx . . $ http_request_header(8b4805cea1886632).(req, "if-modified-since", &modified)) { |
| 699 | mtime = kore_date_to_timecxx . . $ kore_date_to_time(3c95bd14d5d5d286).(modified); |
| 700 | if (mtime == ref->mtime_seccxx . . $ kore_fileref#mtime_sec.) { |
| 701 | kore_fileref_releasecxx . . $ kore_fileref_release(6512ee26e70dae5b).(ref); |
| 702 | http_responsecxx . . $ http_response(8f2daeb0fc6e2740).(req, HTTP_STATUS_NOT_MODIFIEDcxx . . $ HTTP_STATUS_NOT_MODIFIED., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0); |
| 703 | return; |
| 704 | } |
| 705 | } |
| 706 | |
| 707 | if ((tm = gmtimecxx . . $ gmtime(9477a1348abbbc5).(&ref->mtime_seccxx . . $ kore_fileref#mtime_sec.)) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 708 | if (strftimecxx . . $ strftime(98e75925167c4f1b).(tbuf, sizeof(tbuf), |
| 709 | "%a, %d %b %Y %H:%M:%S GMT", tm) > 0) { |
| 710 | http_response_headercxx . . $ http_response_header(84119343264ef6a5).(req, "last-modified", tbuf); |
| 711 | } |
| 712 | } |
| 713 | |
| 714 | req->statuscxx . . $ http_request#status. = status; |
| 715 | switch (req->ownercxx . . $ http_request#owner.->protocxx . . $ connection#proto.) { |
| 716 | case CONN_PROTO_HTTPcxx . . $ `include/kore/kore.h:182:9`!: |
| 717 | http_response_normalcxx . . $ http_response_normal(22e994f97d4c6aa9).(req, req->ownercxx . . $ http_request#owner., status, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, ref->sizecxx . . $ kore_fileref#size.); |
| 718 | break; |
| 719 | default: |
| 720 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("http_response_fd() bad proto %d", req->ownercxx . . $ http_request#owner.->protocxx . . $ connection#proto.); |
| 721 | /* NOTREACHED. */ |
| 722 | } |
| 723 | |
| 724 | if (req->methodcxx . . $ http_request#method. != HTTP_METHOD_HEADcxx . . $ `include/kore/http.h:233:9`!) |
| 725 | net_send_filerefcxx . . $ net_send_fileref(ae27ba2f4cacc904).(req->ownercxx . . $ http_request#owner., ref); |
| 726 | else |
| 727 | kore_fileref_releasecxx . . $ kore_fileref_release(6512ee26e70dae5b).(ref); |
| 728 | } |
| 729 | |
| 730 | int |
| 731 | http_request_headercxx . . $ http_request_header(8b4805cea1886632).(struct http_requestcxx . . $ http_request# *req, const char *header, |
| 732 | const char **out) |
| 733 | { |
| 734 | struct http_headercxx . . $ http_header# *hdr; |
| 735 | |
| 736 | TAILQ_FOREACHcxx . . $ `<external>/2546723208511035544/queue.h:435:9`!(hdr, &(req->req_headers), list) { |
| 737 | if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(hdr->headercxx . . $ http_header#header., header)) { |
| 738 | *out = hdr->valuecxx . . $ http_header#value.; |
| 739 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 740 | } |
| 741 | } |
| 742 | |
| 743 | if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(header, "host")) { |
| 744 | *out = req->hostcxx . . $ http_request#host.; |
| 745 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 746 | } |
| 747 | |
| 748 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 749 | } |
| 750 | |
| 751 | int |
| 752 | http_request_header_getcxx . . $ http_request_header_get(f3b1026650f9cee).(struct http_requestcxx . . $ http_request# *req, const char *header, |
| 753 | void **out, void *nout, int type) |
| 754 | { |
| 755 | struct http_headercxx . . $ http_header# *hdr; |
| 756 | |
| 757 | if (type == HTTP_ARG_TYPE_STRINGcxx . . $ `include/kore/http.h:63:9`!) |
| 758 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("%s: cannot be called with type string", __func__); |
| 759 | |
| 760 | TAILQ_FOREACHcxx . . $ `<external>/2546723208511035544/queue.h:435:9`!(hdr, &req->req_headers, list) { |
| 761 | if (strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(hdr->headercxx . . $ http_header#header., header)) |
| 762 | continue; |
| 763 | |
| 764 | if (http_data_convertcxx . . $ http_data_convert(68f79bd69bedc53).(hdr->valuecxx . . $ http_header#value., out, nout, type)) |
| 765 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 766 | |
| 767 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 768 | } |
| 769 | |
| 770 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 771 | } |
| 772 | |
| 773 | int |
| 774 | http_request_cookiecxx . . $ http_request_cookie(90f43aa9f1244edc).(struct http_requestcxx . . $ http_request# *req, const char *cookie, char **out) |
| 775 | { |
| 776 | struct http_cookiecxx . . $ http_cookie# *ck; |
| 777 | |
| 778 | TAILQ_FOREACHcxx . . $ `<external>/2546723208511035544/queue.h:435:9`!(ck, &(req->req_cookies), list) { |
| 779 | if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(ck->namecxx . . $ http_cookie#name., cookie)) { |
| 780 | *out = ck->valuecxx . . $ http_cookie#value.; |
| 781 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 782 | } |
| 783 | } |
| 784 | |
| 785 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 786 | } |
| 787 | |
| 788 | int |
| 789 | http_header_recvcxx . . $ http_header_recv(82c4d452dc2a871a).(struct netbufcxx . . $ netbuf# *nb) |
| 790 | { |
| 791 | struct connectioncxx . . $ connection# *c; |
| 792 | size_t len; |
| 793 | struct http_headercxx . . $ http_header# *hdr; |
| 794 | struct http_requestcxx . . $ http_request# *req; |
| 795 | u_int8_tcxx . . $ u_int8_t# *end_headers; |
| 796 | int h, i, v, skip, l; |
| 797 | char *headers[HTTP_REQ_HEADER_MAXcxx . . $ `include/kore/http.h:41:9`!]; |
| 798 | char *value, *host, *request[4], *hbuf; |
| 799 | |
| 800 | c = nb->ownercxx . . $ netbuf#owner.; |
| 801 | |
| 802 | if (nb->b_lencxx . . $ netbuf#b_len. < 4) |
| 803 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 804 | |
| 805 | if (!isalphacxx . . $ `<external>/17904084882347303253/ctype.h:190:10`!(nb->buf[0])) { |
| 806 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_BAD_REQUESTcxx . . $ HTTP_STATUS_BAD_REQUEST.); |
| 807 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 808 | } |
| 809 | |
| 810 | skip = 4; |
| 811 | end_headers = kore_mem_findcxx . . $ kore_mem_find(d6408e6ff8ad1a7e).(nb->bufcxx . . $ netbuf#buf., nb->s_offcxx . . $ netbuf#s_off., "\r\n\r\n", 4); |
| 812 | if (end_headers == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 813 | end_headers = kore_mem_findcxx . . $ kore_mem_find(d6408e6ff8ad1a7e).(nb->bufcxx . . $ netbuf#buf., nb->s_offcxx . . $ netbuf#s_off., "\n\n", 2); |
| 814 | if (end_headers == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 815 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 816 | skip = 2; |
| 817 | } |
| 818 | |
| 819 | *end_headers = '\0'; |
| 820 | end_headers += skip; |
| 821 | len = end_headers - nb->bufcxx . . $ netbuf#buf.; |
| 822 | hbuf = (char *)nb->bufcxx . . $ netbuf#buf.; |
| 823 | |
| 824 | h = kore_split_stringcxx . . $ kore_split_string(87b756e43bd5489c).(hbuf, "\r\n", headers, HTTP_REQ_HEADER_MAXcxx . . $ `include/kore/http.h:41:9`!); |
| 825 | if (h < 2) { |
| 826 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_BAD_REQUESTcxx . . $ HTTP_STATUS_BAD_REQUEST.); |
| 827 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 828 | } |
| 829 | |
| 830 | v = kore_split_stringcxx . . $ kore_split_string(87b756e43bd5489c).(headers[0], " ", request, 4); |
| 831 | if (v != 3) { |
| 832 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_BAD_REQUESTcxx . . $ HTTP_STATUS_BAD_REQUEST.); |
| 833 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 834 | } |
| 835 | |
| 836 | skip = 0; |
| 837 | host = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 838 | for (i = 0; i < h; i++) { |
| 839 | if (strncasecmpcxx . . $ strncasecmp(fd278af2f295fa2e).(headers[i], "host", 4)) |
| 840 | continue; |
| 841 | |
| 842 | if ((host = http_validate_headercxx . . $ http_validate_header(7a9722d75b371431).(headers[i])) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 843 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_BAD_REQUESTcxx . . $ HTTP_STATUS_BAD_REQUEST.); |
| 844 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 845 | } |
| 846 | |
| 847 | if (*host == '\0') { |
| 848 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_BAD_REQUESTcxx . . $ HTTP_STATUS_BAD_REQUEST.); |
| 849 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 850 | } |
| 851 | |
| 852 | skip = i; |
| 853 | break; |
| 854 | } |
| 855 | |
| 856 | if (host == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 857 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_BAD_REQUESTcxx . . $ HTTP_STATUS_BAD_REQUEST.); |
| 858 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 859 | } |
| 860 | |
| 861 | req = http_request_newcxx . . $ http_request_new(f7dd24d21b927557).(c, host, request[0], request[1], request[2]); |
| 862 | if (req == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 863 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 864 | |
| 865 | /* take full ownership of the buffer. */ |
| 866 | req->headerscxx . . $ http_request#headers. = nb->bufcxx . . $ netbuf#buf.; |
| 867 | nb->bufcxx . . $ netbuf#buf. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 868 | nb->m_lencxx . . $ netbuf#m_len. = 0; |
| 869 | |
| 870 | for (i = 1; i < h; i++) { |
| 871 | if (i == skip) |
| 872 | continue; |
| 873 | |
| 874 | if ((value = http_validate_headercxx . . $ http_validate_header(7a9722d75b371431).(headers[i])) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 875 | req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_DELETEcxx . . $ `include/kore/http.h:242:9`!; |
| 876 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_BAD_REQUESTcxx . . $ HTTP_STATUS_BAD_REQUEST.); |
| 877 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 878 | } |
| 879 | |
| 880 | if (*value == '\0') { |
| 881 | req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_DELETEcxx . . $ `include/kore/http.h:242:9`!; |
| 882 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_BAD_REQUESTcxx . . $ HTTP_STATUS_BAD_REQUEST.); |
| 883 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 884 | } |
| 885 | |
| 886 | hdr = kore_pool_getcxx . . $ kore_pool_get(f5c578167d321b17).(&http_header_poolcxx . . $ http_header_pool.); |
| 887 | hdr->headercxx . . $ http_header#header. = headers[i]; |
| 888 | hdr->valuecxx . . $ http_header#value. = value; |
| 889 | TAILQ_INSERT_TAILcxx . . $ `<external>/2546723208511035544/queue.h:402:9`!(&(req->req_headers), hdr, list); |
| 890 | |
| 891 | if (req->agentcxx . . $ http_request#agent. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && |
| 892 | !strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(hdr->headercxx . . $ http_header#header., "user-agent")) |
| 893 | req->agentcxx . . $ http_request#agent. = hdr->valuecxx . . $ http_header#value.; |
| 894 | |
| 895 | if (req->referercxx . . $ http_request#referer. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && |
| 896 | !strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(hdr->headercxx . . $ http_header#header., "referer")) |
| 897 | req->referercxx . . $ http_request#referer. = hdr->valuecxx . . $ http_header#value.; |
| 898 | } |
| 899 | |
| 900 | if (req->flagscxx . . $ http_request#flags. & HTTP_REQUEST_EXPECT_BODYcxx . . $ `include/kore/http.h:244:9`!) { |
| 901 | if (http_body_maxcxx . . $ http_body_max. == 0) { |
| 902 | req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_DELETEcxx . . $ `include/kore/http.h:242:9`!; |
| 903 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(req->ownercxx . . $ http_request#owner., |
| 904 | HTTP_STATUS_METHOD_NOT_ALLOWEDcxx . . $ HTTP_STATUS_METHOD_NOT_ALLOWED.); |
| 905 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 906 | } |
| 907 | |
| 908 | if (!http_request_header_uint64cxx . . $ `include/kore/http.h:207:9`!(req, "content-length", |
| 909 | &req->content_length)) { |
| 910 | if (req->methodcxx . . $ http_request#method. == HTTP_METHOD_DELETEcxx . . $ `include/kore/http.h:232:9`!) { |
| 911 | req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_COMPLETEcxx . . $ `include/kore/http.h:241:9`!; |
| 912 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 913 | } |
| 914 | |
| 915 | req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_DELETEcxx . . $ `include/kore/http.h:242:9`!; |
| 916 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(req->ownercxx . . $ http_request#owner., |
| 917 | HTTP_STATUS_LENGTH_REQUIREDcxx . . $ HTTP_STATUS_LENGTH_REQUIRED.); |
| 918 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 919 | } |
| 920 | |
| 921 | if (req->content_lengthcxx . . $ http_request#content_length. == 0) { |
| 922 | req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_COMPLETEcxx . . $ `include/kore/http.h:241:9`!; |
| 923 | req->flagscxx . . $ http_request#flags. &= ~HTTP_REQUEST_EXPECT_BODYcxx . . $ `include/kore/http.h:244:9`!; |
| 924 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 925 | } |
| 926 | |
| 927 | if (req->content_lengthcxx . . $ http_request#content_length. > http_body_maxcxx . . $ http_body_max.) { |
| 928 | req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_DELETEcxx . . $ `include/kore/http.h:242:9`!; |
| 929 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(req->ownercxx . . $ http_request#owner., |
| 930 | HTTP_STATUS_REQUEST_ENTITY_TOO_LARGEcxx . . $ HTTP_STATUS_REQUEST_ENTITY_TOO_LARGE.); |
| 931 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 932 | } |
| 933 | |
| 934 | req->http_body_lengthcxx . . $ http_request#http_body_length. = req->content_lengthcxx . . $ http_request#content_length.; |
| 935 | |
| 936 | if (http_body_disk_offloadcxx . . $ http_body_disk_offload. > 0 && |
| 937 | req->content_lengthcxx . . $ http_request#content_length. > http_body_disk_offloadcxx . . $ http_body_disk_offload.) { |
| 938 | req->http_body_pathcxx . . $ http_request#http_body_path. = kore_pool_getcxx . . $ kore_pool_get(f5c578167d321b17).(&http_body_pathcxx . . $ http_body_path.); |
| 939 | l = snprintfcxx . . $ snprintf(ea502d73e74c754c).(req->http_body_pathcxx . . $ http_request#http_body_path., HTTP_BODY_PATH_MAXcxx . . $ `include/kore/http.h:52:9`!, |
| 940 | "%s/http_body.XXXXXX", http_body_disk_pathcxx . . $ http_body_disk_path.); |
| 941 | if (l == -1 || (size_t)l >= HTTP_BODY_PATH_MAXcxx . . $ `include/kore/http.h:52:9`!) { |
| 942 | req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_DELETEcxx . . $ `include/kore/http.h:242:9`!; |
| 943 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(req->ownercxx . . $ http_request#owner., |
| 944 | HTTP_STATUS_INTERNAL_ERRORcxx . . $ HTTP_STATUS_INTERNAL_ERROR.); |
| 945 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 946 | } |
| 947 | |
| 948 | req->http_bodycxx . . $ http_request#http_body. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 949 | req->http_body_fdcxx . . $ http_request#http_body_fd. = mkstempcxx . . $ mkstemp(1ef8e6ec083aabb9).(req->http_body_pathcxx . . $ http_request#http_body_path.); |
| 950 | if (req->http_body_fdcxx . . $ http_request#http_body_fd. == -1) { |
| 951 | req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_DELETEcxx . . $ `include/kore/http.h:242:9`!; |
| 952 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(req->ownercxx . . $ http_request#owner., |
| 953 | HTTP_STATUS_INTERNAL_ERRORcxx . . $ HTTP_STATUS_INTERNAL_ERROR.); |
| 954 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 955 | } |
| 956 | } else { |
| 957 | req->http_body_fdcxx . . $ http_request#http_body_fd. = -1; |
| 958 | req->http_bodycxx . . $ http_request#http_body. = kore_buf_alloccxx . . $ kore_buf_alloc(ae982dcc82edde78).(req->content_lengthcxx . . $ http_request#content_length.); |
| 959 | } |
| 960 | |
| 961 | SHA256Initcxx . . $ SHA256Init(107183565cad2912).(&req->hashctxcxx . . $ http_request#hashctx.); |
| 962 | c->http_timeoutcxx . . $ connection#http_timeout. = http_body_timeoutcxx . . $ http_body_timeout. * 1000; |
| 963 | |
| 964 | if (!http_body_updatecxx . . $ http_body_update(eef2fffe5d7d9806).(req, end_headers, nb->s_offcxx . . $ netbuf#s_off. - len)) { |
| 965 | req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_DELETEcxx . . $ `include/kore/http.h:242:9`!; |
| 966 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(req->ownercxx . . $ http_request#owner., |
| 967 | HTTP_STATUS_INTERNAL_ERRORcxx . . $ HTTP_STATUS_INTERNAL_ERROR.); |
| 968 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 969 | } |
| 970 | } else { |
| 971 | c->http_timeoutcxx . . $ connection#http_timeout. = 0; |
| 972 | } |
| 973 | |
| 974 | if (req->rtcxx . . $ http_request#rt.->on_headerscxx . . $ kore_route#on_headers. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 975 | if (!kore_runtime_http_requestcxx . . $ kore_runtime_http_request(2cad211aba5d4032).(req->rtcxx . . $ http_request#rt.->on_headerscxx . . $ kore_route#on_headers., req)) { |
| 976 | req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_DELETEcxx . . $ `include/kore/http.h:242:9`!; |
| 977 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 978 | } |
| 979 | } |
| 980 | |
| 981 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 982 | } |
| 983 | |
| 984 | int |
| 985 | http_argument_getcxx . . $ http_argument_get(f3b1026650f9cee).(struct http_requestcxx . . $ http_request# *req, const char *name, |
| 986 | void **out, void *nout, int type) |
| 987 | { |
| 988 | struct http_argcxx . . $ http_arg# *q; |
| 989 | |
| 990 | TAILQ_FOREACHcxx . . $ `<external>/2546723208511035544/queue.h:435:9`!(q, &(req->arguments), list) { |
| 991 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(q->namecxx . . $ http_arg#name., name)) |
| 992 | continue; |
| 993 | |
| 994 | if (http_data_convertcxx . . $ http_data_convert(68f79bd69bedc53).(q->s_valuecxx . . $ http_arg#s_value., out, nout, type)) |
| 995 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 996 | |
| 997 | break; |
| 998 | } |
| 999 | |
| 1000 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 1001 | } |
| 1002 | |
| 1003 | int |
| 1004 | http_argument_urldecodecxx . . $ http_argument_urldecode(1ef8e6ec083aabb9).(char *arg) |
| 1005 | { |
| 1006 | u_int8_tcxx . . $ u_int8_t# v; |
| 1007 | int err; |
| 1008 | size_t len; |
| 1009 | char *p, *in, h[5]; |
| 1010 | |
| 1011 | p = arg; |
| 1012 | in = arg; |
| 1013 | len = strlencxx . . $ strlen(751346f8406fd082).(arg); |
| 1014 | |
| 1015 | while (*p != '\0' && p < (arg + len)) { |
| 1016 | if (*p == '+') |
| 1017 | *p = ' '; |
| 1018 | if (*p != '%') { |
| 1019 | *in++ = *p++; |
| 1020 | continue; |
| 1021 | } |
| 1022 | |
| 1023 | if ((p + 2) >= (arg + len)) |
| 1024 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 1025 | |
| 1026 | if (!isxdigitcxx . . $ `<external>/17904084882347303253/ctype.h:199:10`!((unsigned char)*(p + 1)) || |
| 1027 | !isxdigitcxx . . $ `<external>/17904084882347303253/ctype.h:199:10`!((unsigned char)*(p + 2))) { |
| 1028 | *in++ = *p++; |
| 1029 | continue; |
| 1030 | } |
| 1031 | |
| 1032 | h[0] = '0'; |
| 1033 | h[1] = 'x'; |
| 1034 | h[2] = *(p + 1); |
| 1035 | h[3] = *(p + 2); |
| 1036 | h[4] = '\0'; |
| 1037 | |
| 1038 | v = kore_strtonumcxx . . $ kore_strtonum(1c42d1a447034a9d).(h, 16, 0x0, 0xff, &err); |
| 1039 | if (err != KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!) |
| 1040 | return (err); |
| 1041 | |
| 1042 | if (v <= 0x1f || v == 0x7f) |
| 1043 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 1044 | |
| 1045 | *in++ = (char)v; |
| 1046 | p += 3; |
| 1047 | } |
| 1048 | |
| 1049 | *in = '\0'; |
| 1050 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 1051 | } |
| 1052 | |
| 1053 | struct http_filecxx . . $ http_file# * |
| 1054 | http_file_lookupcxx . . $ http_file_lookup(463441d2c6522d03).(struct http_requestcxx . . $ http_request# *req, const char *name) |
| 1055 | { |
| 1056 | struct http_filecxx . . $ http_file# *f; |
| 1057 | |
| 1058 | TAILQ_FOREACHcxx . . $ `<external>/2546723208511035544/queue.h:435:9`!(f, &(req->files), list) { |
| 1059 | if (!strcmpcxx . . $ strcmp(5ae29d726ae57f88).(f->namecxx . . $ http_file#name., name)) |
| 1060 | return (f); |
| 1061 | } |
| 1062 | |
| 1063 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1064 | } |
| 1065 | |
| 1066 | ssize_tcxx . . $ ssize_t# |
| 1067 | http_file_readcxx . . $ http_file_read(9f28acf2a3299c3a).(struct http_filecxx . . $ http_file# *file, void *buf, size_t len) |
| 1068 | { |
| 1069 | ssize_tcxx . . $ ssize_t# ret; |
| 1070 | size_t toread, off; |
| 1071 | |
| 1072 | if (file->lengthcxx . . $ http_file#length. < file->offsetcxx . . $ http_file#offset.) |
| 1073 | return (-1); |
| 1074 | if ((file->offsetcxx . . $ http_file#offset. + len) < file->offsetcxx . . $ http_file#offset.) |
| 1075 | return (-1); |
| 1076 | if ((file->positioncxx . . $ http_file#position. + file->offsetcxx . . $ http_file#offset.) < file->positioncxx . . $ http_file#position.) |
| 1077 | return (-1); |
| 1078 | |
| 1079 | off = file->positioncxx . . $ http_file#position. + file->offsetcxx . . $ http_file#offset.; |
| 1080 | toread = MINcxx . . $ `<external>/1231830743887005719/param.h:102:9`!(len, (file->length - file->offset)); |
| 1081 | if (toread == 0) |
| 1082 | return (0); |
| 1083 | |
| 1084 | if (file->reqcxx . . $ http_file#req.->http_body_fdcxx . . $ http_request#http_body_fd. != -1) { |
| 1085 | if (lseekcxx . . $ lseek(f1afe674ac17c82e).(file->reqcxx . . $ http_file#req.->http_body_fdcxx . . $ http_request#http_body_fd., off, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:110:9`!) == -1) { |
| 1086 | kore_logcxx . . $ kore_log(afcfcee7634adf7d).(LOG_ERRcxx . . $ `<external>/6168640806541382331/syslog.h:54:9`!, "http_file_read: lseek(%s): %s", |
| 1087 | file->reqcxx . . $ http_file#req.->http_body_pathcxx . . $ http_request#http_body_path., errno_scxx . . $ `include/kore/kore.h:100:9`!); |
| 1088 | return (-1); |
| 1089 | } |
| 1090 | |
| 1091 | for (;;) { |
| 1092 | ret = readcxx . . $ read(7e34d0a36f355389).(file->reqcxx . . $ http_file#req.->http_body_fdcxx . . $ http_request#http_body_fd., buf, toread); |
| 1093 | if (ret == -1) { |
| 1094 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == EINTRcxx . . $ `<external>/8987895939074593727/errno-base.h:8:9`!) |
| 1095 | continue; |
| 1096 | kore_logcxx . . $ kore_log(afcfcee7634adf7d).(LOG_ERRcxx . . $ `<external>/6168640806541382331/syslog.h:54:9`!, "failed to read %s: %s", |
| 1097 | file->reqcxx . . $ http_file#req.->http_body_pathcxx . . $ http_request#http_body_path., errno_scxx . . $ `include/kore/kore.h:100:9`!); |
| 1098 | return (-1); |
| 1099 | } |
| 1100 | if (ret == 0) |
| 1101 | return (0); |
| 1102 | break; |
| 1103 | } |
| 1104 | } else if (file->reqcxx . . $ http_file#req.->http_bodycxx . . $ http_request#http_body. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1105 | if (off > file->reqcxx . . $ http_file#req.->http_bodycxx . . $ http_request#http_body.->lengthcxx . . $ kore_buf#length.) |
| 1106 | return (0); |
| 1107 | memcpycxx . . $ memcpy(cc817cb175f282d).(buf, file->reqcxx . . $ http_file#req.->http_bodycxx . . $ http_request#http_body.->datacxx . . $ kore_buf#data. + off, toread); |
| 1108 | ret = toread; |
| 1109 | } else { |
| 1110 | kore_logcxx . . $ kore_log(afcfcee7634adf7d).(LOG_ERRcxx . . $ `<external>/6168640806541382331/syslog.h:54:9`!, "http_file_read: called without body"); |
| 1111 | return (-1); |
| 1112 | } |
| 1113 | |
| 1114 | file->offsetcxx . . $ http_file#offset. += (size_t)ret; |
| 1115 | return (ret); |
| 1116 | } |
| 1117 | |
| 1118 | void |
| 1119 | http_file_rewindcxx . . $ http_file_rewind(a5fdbfdfdcf0ec4f).(struct http_filecxx . . $ http_file# *file) |
| 1120 | { |
| 1121 | file->offsetcxx . . $ http_file#offset. = 0; |
| 1122 | } |
| 1123 | |
| 1124 | void |
| 1125 | http_response_cookiecxx . . $ http_response_cookie(32a80964a387db67).(struct http_requestcxx . . $ http_request# *req, const char *name, |
| 1126 | const char *val, const char *path, time_tcxx . . $ time_t# expires, u_int32_tcxx . . $ u_int32_t# maxage, |
| 1127 | struct http_cookiecxx . . $ http_cookie# **out) |
| 1128 | { |
| 1129 | char *p; |
| 1130 | struct http_cookiecxx . . $ http_cookie# *ck; |
| 1131 | |
| 1132 | if (name == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || val == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1133 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("http_response_cookie: invalid parameters"); |
| 1134 | |
| 1135 | ck = kore_pool_getcxx . . $ kore_pool_get(f5c578167d321b17).(&http_cookie_poolcxx . . $ http_cookie_pool.); |
| 1136 | |
| 1137 | ck->maxagecxx . . $ http_cookie#maxage. = maxage; |
| 1138 | ck->expirescxx . . $ http_cookie#expires. = expires; |
| 1139 | ck->namecxx . . $ http_cookie#name. = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(name); |
| 1140 | ck->valuecxx . . $ http_cookie#value. = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(val); |
| 1141 | ck->domaincxx . . $ http_cookie#domain. = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(req->hostcxx . . $ http_request#host.); |
| 1142 | ck->flagscxx . . $ http_cookie#flags. = HTTP_COOKIE_HTTPONLYcxx . . $ `include/kore/http.h:91:9`! | HTTP_COOKIE_SECUREcxx . . $ `include/kore/http.h:92:9`!; |
| 1143 | |
| 1144 | if ((p = strrchrcxx . . $ strrchr(2050848944e00d54).(ck->domaincxx . . $ http_cookie#domain., ':')) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1145 | *p = '\0'; |
| 1146 | |
| 1147 | if (path != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1148 | ck->pathcxx . . $ http_cookie#path. = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(path); |
| 1149 | else |
| 1150 | ck->pathcxx . . $ http_cookie#path. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1151 | |
| 1152 | TAILQ_INSERT_TAILcxx . . $ `<external>/2546723208511035544/queue.h:402:9`!(&(req->resp_cookies), ck, list); |
| 1153 | |
| 1154 | if (out != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1155 | *out = ck; |
| 1156 | } |
| 1157 | |
| 1158 | void |
| 1159 | http_populate_cookiescxx . . $ http_populate_cookies(322c51a23f687f95).(struct http_requestcxx . . $ http_request# *req) |
| 1160 | { |
| 1161 | struct http_cookiecxx . . $ http_cookie# *ck; |
| 1162 | const char *hdr; |
| 1163 | int i, v, n; |
| 1164 | char *c, *header, *pair[3]; |
| 1165 | char *cookies[HTTP_MAX_COOKIEScxx . . $ `include/kore/http.h:43:9`!]; |
| 1166 | |
| 1167 | if (!http_request_headercxx . . $ http_request_header(8b4805cea1886632).(req, "cookie", &hdr)) |
| 1168 | return; |
| 1169 | |
| 1170 | header = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(hdr); |
| 1171 | v = kore_split_stringcxx . . $ kore_split_string(87b756e43bd5489c).(header, ";", cookies, HTTP_MAX_COOKIEScxx . . $ `include/kore/http.h:43:9`!); |
| 1172 | for (i = 0; i < v; i++) { |
| 1173 | for (c = cookies[i]; isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*(unsigned char *)c); c++) |
| 1174 | ; |
| 1175 | |
| 1176 | n = kore_split_stringcxx . . $ kore_split_string(87b756e43bd5489c).(c, "=", pair, 3); |
| 1177 | if (n != 2) |
| 1178 | continue; |
| 1179 | |
| 1180 | ck = kore_pool_getcxx . . $ kore_pool_get(f5c578167d321b17).(&http_cookie_poolcxx . . $ http_cookie_pool.); |
| 1181 | ck->namecxx . . $ http_cookie#name. = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(pair[0]); |
| 1182 | ck->valuecxx . . $ http_cookie#value. = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(pair[1]); |
| 1183 | TAILQ_INSERT_TAILcxx . . $ `<external>/2546723208511035544/queue.h:402:9`!(&(req->req_cookies), ck, list); |
| 1184 | } |
| 1185 | |
| 1186 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(header); |
| 1187 | } |
| 1188 | |
| 1189 | void |
| 1190 | http_populate_postcxx . . $ http_populate_post(322c51a23f687f95).(struct http_requestcxx . . $ http_request# *req) |
| 1191 | { |
| 1192 | ssize_tcxx . . $ ssize_t# ret; |
| 1193 | int i, v; |
| 1194 | struct kore_bufcxx . . $ kore_buf# *body; |
| 1195 | char data[BUFSIZcxx . . $ `<external>/232824719582829767/stdio.h:100:9`!]; |
| 1196 | char *args[HTTP_MAX_QUERY_ARGScxx . . $ `include/kore/http.h:42:9`!], *val[3], *string; |
| 1197 | |
| 1198 | if (req->methodcxx . . $ http_request#method. != HTTP_METHOD_POSTcxx . . $ `include/kore/http.h:230:9`!) |
| 1199 | return; |
| 1200 | |
| 1201 | if (req->http_bodycxx . . $ http_request#http_body. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1202 | body = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1203 | req->http_bodycxx . . $ http_request#http_body.->offsetcxx . . $ kore_buf#offset. = req->content_lengthcxx . . $ http_request#content_length.; |
| 1204 | string = kore_buf_stringifycxx . . $ kore_buf_stringify(4bc5b263e10e2f7b).(req->http_bodycxx . . $ http_request#http_body., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1205 | req->http_body_lengthcxx . . $ http_request#http_body_length. = 0; |
| 1206 | req->http_body_offsetcxx . . $ http_request#http_body_offset. = 0; |
| 1207 | } else { |
| 1208 | body = kore_buf_alloccxx . . $ kore_buf_alloc(ae982dcc82edde78).(128); |
| 1209 | for (;;) { |
| 1210 | ret = http_body_readcxx . . $ http_body_read(da9cfe03a73e7462).(req, data, sizeof(data)); |
| 1211 | if (ret == -1) |
| 1212 | goto out; |
| 1213 | if (ret == 0) |
| 1214 | break; |
| 1215 | kore_buf_appendcxx . . $ kore_buf_append(4909ebf68ec24f4d).(body, data, ret); |
| 1216 | } |
| 1217 | string = kore_buf_stringifycxx . . $ kore_buf_stringify(4bc5b263e10e2f7b).(body, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1218 | } |
| 1219 | |
| 1220 | v = kore_split_stringcxx . . $ kore_split_string(87b756e43bd5489c).(string, "&", args, HTTP_MAX_QUERY_ARGScxx . . $ `include/kore/http.h:42:9`!); |
| 1221 | for (i = 0; i < v; i++) { |
| 1222 | kore_split_stringcxx . . $ kore_split_string(87b756e43bd5489c).(args[i], "=", val, 3); |
| 1223 | if (val[0] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && val[1] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1224 | http_argument_addcxx . . $ http_argument_add(a82b44345cf8406a).(req, val[0], val[1], 0, 1); |
| 1225 | } |
| 1226 | |
| 1227 | out: |
| 1228 | if (body != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1229 | kore_buf_freecxx . . $ kore_buf_free(2648f45d13d14762).(body); |
| 1230 | } |
| 1231 | |
| 1232 | void |
| 1233 | http_populate_qscxx . . $ http_populate_qs(322c51a23f687f95).(struct http_requestcxx . . $ http_request# *req) |
| 1234 | { |
| 1235 | int i, v; |
| 1236 | char *query, *args[HTTP_MAX_QUERY_ARGScxx . . $ `include/kore/http.h:42:9`!], *val[3]; |
| 1237 | |
| 1238 | if (req->query_stringcxx . . $ http_request#query_string. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1239 | return; |
| 1240 | |
| 1241 | query = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(req->query_stringcxx . . $ http_request#query_string.); |
| 1242 | v = kore_split_stringcxx . . $ kore_split_string(87b756e43bd5489c).(query, "&", args, HTTP_MAX_QUERY_ARGScxx . . $ `include/kore/http.h:42:9`!); |
| 1243 | for (i = 0; i < v; i++) { |
| 1244 | kore_split_stringcxx . . $ kore_split_string(87b756e43bd5489c).(args[i], "=", val, 3); |
| 1245 | if (val[0] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && val[1] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1246 | http_argument_addcxx . . $ http_argument_add(a82b44345cf8406a).(req, val[0], val[1], 1, 1); |
| 1247 | } |
| 1248 | |
| 1249 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(query); |
| 1250 | } |
| 1251 | |
| 1252 | void |
| 1253 | http_populate_multipart_formcxx . . $ http_populate_multipart_form(322c51a23f687f95).(struct http_requestcxx . . $ http_request# *req) |
| 1254 | { |
| 1255 | const char *hdr; |
| 1256 | int h, blen; |
| 1257 | struct kore_bufcxx . . $ kore_buf# in, out; |
| 1258 | char *type, *val, *args[3]; |
| 1259 | char boundary[HTTP_BOUNDARY_MAXcxx . . $ `include/kore/http.h:53:9`!]; |
| 1260 | |
| 1261 | if (req->methodcxx . . $ http_request#method. != HTTP_METHOD_POSTcxx . . $ `include/kore/http.h:230:9`!) |
| 1262 | return; |
| 1263 | |
| 1264 | if (!http_request_headercxx . . $ http_request_header(8b4805cea1886632).(req, "content-type", &hdr)) |
| 1265 | return; |
| 1266 | |
| 1267 | kore_buf_initcxx . . $ kore_buf_init(bd90e0817a56138f).(&in, 128); |
| 1268 | kore_buf_initcxx . . $ kore_buf_init(bd90e0817a56138f).(&out, 128); |
| 1269 | |
| 1270 | type = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(hdr); |
| 1271 | h = kore_split_stringcxx . . $ kore_split_string(87b756e43bd5489c).(type, ";", args, 3); |
| 1272 | if (h != 2) |
| 1273 | goto cleanup; |
| 1274 | |
| 1275 | if (strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(args[0], "multipart/form-data")) |
| 1276 | goto cleanup; |
| 1277 | |
| 1278 | if ((val = strchrcxx . . $ strchr(2050848944e00d54).(args[1], '=')) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1279 | goto cleanup; |
| 1280 | |
| 1281 | val++; |
| 1282 | blen = snprintfcxx . . $ snprintf(ea502d73e74c754c).(boundary, sizeof(boundary), "--%s", val); |
| 1283 | if (blen == -1 || (size_t)blen >= sizeof(boundary)) |
| 1284 | goto cleanup; |
| 1285 | |
| 1286 | if (!multipart_find_datacxx . . $ multipart_find_data(30566873e75e1a09).(&in, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, req, boundary, blen)) |
| 1287 | goto cleanup; |
| 1288 | |
| 1289 | for (;;) { |
| 1290 | if (!multipart_find_datacxx . . $ multipart_find_data(30566873e75e1a09).(&in, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, req, "\r\n", 2)) |
| 1291 | break; |
| 1292 | if (in.offsetcxx . . $ kore_buf#offset. < 4 && req->http_body_lengthcxx . . $ http_request#http_body_length. == 0) |
| 1293 | break; |
| 1294 | if (!multipart_find_datacxx . . $ multipart_find_data(30566873e75e1a09).(&in, &out, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, req, "\r\n\r\n", 4)) |
| 1295 | break; |
| 1296 | if (!multipart_parse_headerscxx . . $ multipart_parse_headers(76feff133a1f576a).(req, &in, &out, boundary, blen)) |
| 1297 | break; |
| 1298 | |
| 1299 | kore_buf_resetcxx . . $ kore_buf_reset(2648f45d13d14762).(&out); |
| 1300 | } |
| 1301 | |
| 1302 | cleanup: |
| 1303 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(type); |
| 1304 | kore_buf_cleanupcxx . . $ kore_buf_cleanup(2648f45d13d14762).(&in); |
| 1305 | kore_buf_cleanupcxx . . $ kore_buf_cleanup(2648f45d13d14762).(&out); |
| 1306 | } |
| 1307 | |
| 1308 | int |
| 1309 | http_body_rewindcxx . . $ http_body_rewind(1f5f2973e69f937).(struct http_requestcxx . . $ http_request# *req) |
| 1310 | { |
| 1311 | if (req->http_body_fdcxx . . $ http_request#http_body_fd. != -1) { |
| 1312 | if (lseekcxx . . $ lseek(f1afe674ac17c82e).(req->http_body_fdcxx . . $ http_request#http_body_fd., 0, SEEK_SETcxx . . $ `<external>/232824719582829767/stdio.h:110:9`!) == -1) { |
| 1313 | kore_logcxx . . $ kore_log(afcfcee7634adf7d).(LOG_ERRcxx . . $ `<external>/6168640806541382331/syslog.h:54:9`!, "lseek(%s) failed: %s", |
| 1314 | req->http_body_pathcxx . . $ http_request#http_body_path., errno_scxx . . $ `include/kore/kore.h:100:9`!); |
| 1315 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 1316 | } |
| 1317 | } else if (req->http_bodycxx . . $ http_request#http_body. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1318 | kore_buf_resetcxx . . $ kore_buf_reset(2648f45d13d14762).(req->http_bodycxx . . $ http_request#http_body.); |
| 1319 | } |
| 1320 | |
| 1321 | req->http_body_offsetcxx . . $ http_request#http_body_offset. = 0; |
| 1322 | req->http_body_lengthcxx . . $ http_request#http_body_length. = req->content_lengthcxx . . $ http_request#content_length.; |
| 1323 | |
| 1324 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 1325 | } |
| 1326 | |
| 1327 | int |
| 1328 | http_body_digestcxx . . $ http_body_digest(8358efb527ffb7bb).(struct http_requestcxx . . $ http_request# *req, char *out, size_t len) |
| 1329 | { |
| 1330 | size_t idx; |
| 1331 | int slen; |
| 1332 | |
| 1333 | if (len != HTTP_BODY_DIGEST_STRLENcxx . . $ `include/kore/http.h:255:9`!) { |
| 1334 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("http_body_digest: bad len:%zu wanted:%u", |
| 1335 | len, HTTP_BODY_DIGEST_STRLENcxx . . $ `include/kore/http.h:255:9`!); |
| 1336 | } |
| 1337 | |
| 1338 | if (!(req->flagscxx . . $ http_request#flags. & HTTP_REQUEST_COMPLETEcxx . . $ `include/kore/http.h:241:9`!)) |
| 1339 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 1340 | |
| 1341 | for (idx = 0; idx < sizeof(req->http_body_digestcxx . . $ http_request#http_body_digest.); idx++) { |
| 1342 | slen = snprintfcxx . . $ snprintf(ea502d73e74c754c).(out + (idx * 2), len - (idx * 2), "%02x", |
| 1343 | req->http_body_digestcxx . . $ http_request#http_body_digest.[idx]); |
| 1344 | if (slen == -1 || (size_t)slen >= len) |
| 1345 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("failed to create hex string"); |
| 1346 | } |
| 1347 | |
| 1348 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 1349 | } |
| 1350 | |
| 1351 | ssize_tcxx . . $ ssize_t# |
| 1352 | http_body_readcxx . . $ http_body_read(da9cfe03a73e7462).(struct http_requestcxx . . $ http_request# *req, void *out, size_t len) |
| 1353 | { |
| 1354 | ssize_tcxx . . $ ssize_t# ret; |
| 1355 | size_t toread; |
| 1356 | |
| 1357 | toread = MINcxx . . $ `<external>/1231830743887005719/param.h:102:9`!(req->http_body_length, len); |
| 1358 | if (toread == 0) |
| 1359 | return (0); |
| 1360 | |
| 1361 | if (req->http_body_fdcxx . . $ http_request#http_body_fd. != -1) { |
| 1362 | for (;;) { |
| 1363 | ret = readcxx . . $ read(7e34d0a36f355389).(req->http_body_fdcxx . . $ http_request#http_body_fd., out, toread); |
| 1364 | if (ret == -1) { |
| 1365 | if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! == EINTRcxx . . $ `<external>/8987895939074593727/errno-base.h:8:9`!) |
| 1366 | continue; |
| 1367 | kore_logcxx . . $ kore_log(afcfcee7634adf7d).(LOG_ERRcxx . . $ `<external>/6168640806541382331/syslog.h:54:9`!, "failed to read %s: %s", |
| 1368 | req->http_body_pathcxx . . $ http_request#http_body_path., errno_scxx . . $ `include/kore/kore.h:100:9`!); |
| 1369 | return (-1); |
| 1370 | } |
| 1371 | if (ret == 0) |
| 1372 | return (0); |
| 1373 | break; |
| 1374 | } |
| 1375 | } else if (req->http_bodycxx . . $ http_request#http_body. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1376 | memcpycxx . . $ memcpy(cc817cb175f282d).(out, |
| 1377 | (req->http_bodycxx . . $ http_request#http_body.->datacxx . . $ kore_buf#data. + req->http_bodycxx . . $ http_request#http_body.->offsetcxx . . $ kore_buf#offset.), toread); |
| 1378 | req->http_bodycxx . . $ http_request#http_body.->offsetcxx . . $ kore_buf#offset. += toread; |
| 1379 | ret = toread; |
| 1380 | } else { |
| 1381 | kore_logcxx . . $ kore_log(afcfcee7634adf7d).(LOG_ERRcxx . . $ `<external>/6168640806541382331/syslog.h:54:9`!, "http_body_read: called without body"); |
| 1382 | return (-1); |
| 1383 | } |
| 1384 | |
| 1385 | req->http_body_lengthcxx . . $ http_request#http_body_length. -= (size_t)ret; |
| 1386 | req->http_body_offsetcxx . . $ http_request#http_body_offset. += (size_t)ret; |
| 1387 | |
| 1388 | return (ret); |
| 1389 | } |
| 1390 | |
| 1391 | int |
| 1392 | http_state_runcxx . . $ http_state_run(d46cf3b1de434b98).(struct http_statecxx . . $ http_state# *states, u_int8_tcxx . . $ u_int8_t# elm, |
| 1393 | struct http_requestcxx . . $ http_request# *req) |
| 1394 | { |
| 1395 | int r, done; |
| 1396 | |
| 1397 | done = 0; |
| 1398 | |
| 1399 | while (!done) { |
| 1400 | if (req->fsm_statecxx . . $ http_request#fsm_state. >= elm) { |
| 1401 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("http_state_run: fsm_state > elm (%d/%d)", |
| 1402 | req->fsm_statecxx . . $ http_request#fsm_state., elm); |
| 1403 | } |
| 1404 | |
| 1405 | r = states[req->fsm_statecxx . . $ http_request#fsm_state.].cbcxx . . $ http_state#cb.(req); |
| 1406 | switch (r) { |
| 1407 | case HTTP_STATE_ERRORcxx . . $ `include/kore/http.h:69:9`!: |
| 1408 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 1409 | case HTTP_STATE_RETRYcxx . . $ `include/kore/http.h:72:9`!: |
| 1410 | return (KORE_RESULT_RETRYcxx . . $ `include/kore/kore.h:89:9`!); |
| 1411 | case HTTP_STATE_CONTINUEcxx . . $ `include/kore/http.h:70:9`!: |
| 1412 | break; |
| 1413 | case HTTP_STATE_COMPLETEcxx . . $ `include/kore/http.h:71:9`!: |
| 1414 | done = 1; |
| 1415 | break; |
| 1416 | default: |
| 1417 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("http_state_run: unknown return value %d", r); |
| 1418 | } |
| 1419 | } |
| 1420 | |
| 1421 | req->fsm_statecxx . . $ http_request#fsm_state. = 0; |
| 1422 | |
| 1423 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 1424 | } |
| 1425 | |
| 1426 | int |
| 1427 | http_state_existscxx . . $ http_state_exists(1f5f2973e69f937).(struct http_requestcxx . . $ http_request# *req) |
| 1428 | { |
| 1429 | return (req->hdlr_extracxx . . $ http_request#hdlr_extra. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1430 | } |
| 1431 | |
| 1432 | void * |
| 1433 | http_state_createcxx . . $ http_state_create(7a3d1347c6f62b15).(struct http_requestcxx . . $ http_request# *req, size_t len) |
| 1434 | { |
| 1435 | if (req->hdlr_extracxx . . $ http_request#hdlr_extra. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1436 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("http_state_create: state already exists"); |
| 1437 | |
| 1438 | req->state_lencxx . . $ http_request#state_len. = len; |
| 1439 | req->hdlr_extracxx . . $ http_request#hdlr_extra. = kore_calloccxx . . $ kore_calloc(63a7bf2941bfcd7a).(1, len); |
| 1440 | |
| 1441 | return (req->hdlr_extracxx . . $ http_request#hdlr_extra.); |
| 1442 | } |
| 1443 | |
| 1444 | void * |
| 1445 | http_state_getcxx . . $ http_state_get(2a0f89de8bbfcc1d).(struct http_requestcxx . . $ http_request# *req) |
| 1446 | { |
| 1447 | return (req->hdlr_extracxx . . $ http_request#hdlr_extra.); |
| 1448 | } |
| 1449 | |
| 1450 | void |
| 1451 | http_state_cleanupcxx . . $ http_state_cleanup(322c51a23f687f95).(struct http_requestcxx . . $ http_request# *req) |
| 1452 | { |
| 1453 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(req->hdlr_extracxx . . $ http_request#hdlr_extra.); |
| 1454 | req->hdlr_extracxx . . $ http_request#hdlr_extra. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1455 | } |
| 1456 | |
| 1457 | void |
| 1458 | http_start_recvcxx . . $ http_start_recv(8475afdb72fd1ebb).(struct connectioncxx . . $ connection# *c) |
| 1459 | { |
| 1460 | c->http_startcxx . . $ connection#http_start. = kore_time_mscxx . . $ kore_time_ms(f708dce9a8856c70).(); |
| 1461 | c->http_timeoutcxx . . $ connection#http_timeout. = http_header_timeoutcxx . . $ http_header_timeout. * 1000; |
| 1462 | net_recv_resetcxx . . $ net_recv_reset(174c4f3588921332).(c, http_header_maxcxx . . $ http_header_max., http_header_recvcxx . . $ http_header_recv(82c4d452dc2a871a).); |
| 1463 | } |
| 1464 | |
| 1465 | void |
| 1466 | http_runlock_initcxx . . $ http_runlock_init(4b70a97b9e7184da).(struct http_runlockcxx . . $ http_runlock# *lock) |
| 1467 | { |
| 1468 | lock->ownercxx . . $ http_runlock#owner. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1469 | LIST_INITcxx . . $ `<external>/2546723208511035544/queue.h:101:9`!(&lock->queue); |
| 1470 | } |
| 1471 | |
| 1472 | int |
| 1473 | http_runlock_acquirecxx . . $ http_runlock_acquire(50e80abd902d202d).(struct http_runlockcxx . . $ http_runlock# *lock, struct http_requestcxx . . $ http_request# *req) |
| 1474 | { |
| 1475 | if (lock->ownercxx . . $ http_runlock#owner. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1476 | if (req->runlockcxx . . $ http_request#runlock. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1477 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("%s: request already waiting on lock", __func__); |
| 1478 | |
| 1479 | req->runlockcxx . . $ http_request#runlock. = kore_pool_getcxx . . $ kore_pool_get(f5c578167d321b17).(&http_rlq_poolcxx . . $ http_rlq_pool.); |
| 1480 | req->runlockcxx . . $ http_request#runlock.->reqcxx . . $ http_runlock_queue#req. = req; |
| 1481 | LIST_INSERT_HEADcxx . . $ `<external>/2546723208511035544/queue.h:120:9`!(&lock->queue, req->runlock, list); |
| 1482 | |
| 1483 | http_request_sleepcxx . . $ http_request_sleep(322c51a23f687f95).(req); |
| 1484 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 1485 | } |
| 1486 | |
| 1487 | lock->ownercxx . . $ http_runlock#owner. = req; |
| 1488 | |
| 1489 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 1490 | } |
| 1491 | |
| 1492 | void |
| 1493 | http_runlock_releasecxx . . $ http_runlock_release(311a0e93296014cd).(struct http_runlockcxx . . $ http_runlock# *lock, struct http_requestcxx . . $ http_request# *req) |
| 1494 | { |
| 1495 | struct http_runlock_queuecxx . . $ http_runlock_queue# *next; |
| 1496 | struct http_requestcxx . . $ http_request# *nextreq; |
| 1497 | |
| 1498 | if (lock->ownercxx . . $ http_runlock#owner. != req) |
| 1499 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("%s: calling request != owner of runlock", __func__); |
| 1500 | |
| 1501 | lock->ownercxx . . $ http_runlock#owner. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1502 | |
| 1503 | if ((next = LIST_FIRSTcxx . . $ `<external>/2546723208511035544/queue.h:143:9`!(&lock->queue)) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1504 | LIST_REMOVEcxx . . $ `<external>/2546723208511035544/queue.h:127:9`!(next, list); |
| 1505 | |
| 1506 | nextreq = next->reqcxx . . $ http_runlock_queue#req.; |
| 1507 | nextreq->runlockcxx . . $ http_request#runlock. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1508 | |
| 1509 | http_request_wakeupcxx . . $ http_request_wakeup(322c51a23f687f95).(nextreq); |
| 1510 | kore_pool_putcxx . . $ kore_pool_put(d9a47b307a51c9d5).(&http_rlq_poolcxx . . $ http_rlq_pool., next); |
| 1511 | } |
| 1512 | } |
| 1513 | |
| 1514 | int |
| 1515 | http_redirect_addcxx . . $ http_redirect_add(992d4bbcd4aebaf).(struct kore_domaincxx . . $ kore_domain# *dom, const char *path, int status, |
| 1516 | const char *target) |
| 1517 | { |
| 1518 | struct http_redirectcxx . . $ http_redirect# *rdr; |
| 1519 | |
| 1520 | rdr = kore_calloccxx . . $ kore_calloc(63a7bf2941bfcd7a).(1, sizeof(*rdr)); |
| 1521 | |
| 1522 | if (regcompcxx . . $ regcomp(aa05013d3db24b3e).(&(rdr->rctxcxx . . $ http_redirect#rctx.), path, REG_EXTENDEDcxx . . $ `<external>/18190116149591951179/regex.h:310:9`!)) { |
| 1523 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(rdr); |
| 1524 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 1525 | } |
| 1526 | |
| 1527 | rdr->statuscxx . . $ http_redirect#status. = status; |
| 1528 | |
| 1529 | if (target != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1530 | rdr->targetcxx . . $ http_redirect#target. = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(target); |
| 1531 | else |
| 1532 | rdr->targetcxx . . $ http_redirect#target. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1533 | |
| 1534 | TAILQ_INSERT_TAILcxx . . $ `<external>/2546723208511035544/queue.h:402:9`!(&dom->redirects, rdr, list); |
| 1535 | |
| 1536 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 1537 | } |
| 1538 | |
| 1539 | const char * |
| 1540 | http_status_textcxx . . $ http_status_text(f7ae7e56280f18ae).(int status) |
| 1541 | { |
| 1542 | const char *r; |
| 1543 | |
| 1544 | switch (status) { |
| 1545 | case HTTP_STATUS_CONTINUEcxx . . $ HTTP_STATUS_CONTINUE.: |
| 1546 | r = "Continue"; |
| 1547 | break; |
| 1548 | case HTTP_STATUS_SWITCHING_PROTOCOLScxx . . $ HTTP_STATUS_SWITCHING_PROTOCOLS.: |
| 1549 | r = "Switching Protocols"; |
| 1550 | break; |
| 1551 | case HTTP_STATUS_OKcxx . . $ HTTP_STATUS_OK.: |
| 1552 | r = "OK"; |
| 1553 | break; |
| 1554 | case HTTP_STATUS_CREATEDcxx . . $ HTTP_STATUS_CREATED.: |
| 1555 | r = "Created"; |
| 1556 | break; |
| 1557 | case HTTP_STATUS_ACCEPTEDcxx . . $ HTTP_STATUS_ACCEPTED.: |
| 1558 | r = "Accepted"; |
| 1559 | break; |
| 1560 | case HTTP_STATUS_NON_AUTHORITATIVEcxx . . $ HTTP_STATUS_NON_AUTHORITATIVE.: |
| 1561 | r = "Non-Authoritative Information"; |
| 1562 | break; |
| 1563 | case HTTP_STATUS_NO_CONTENTcxx . . $ HTTP_STATUS_NO_CONTENT.: |
| 1564 | r = "No Content"; |
| 1565 | break; |
| 1566 | case HTTP_STATUS_RESET_CONTENTcxx . . $ HTTP_STATUS_RESET_CONTENT.: |
| 1567 | r = "Reset Content"; |
| 1568 | break; |
| 1569 | case HTTP_STATUS_PARTIAL_CONTENTcxx . . $ HTTP_STATUS_PARTIAL_CONTENT.: |
| 1570 | r = "Partial Content"; |
| 1571 | break; |
| 1572 | case HTTP_STATUS_MULTIPLE_CHOICEScxx . . $ HTTP_STATUS_MULTIPLE_CHOICES.: |
| 1573 | r = "Multiple Choices"; |
| 1574 | break; |
| 1575 | case HTTP_STATUS_MOVED_PERMANENTLYcxx . . $ HTTP_STATUS_MOVED_PERMANENTLY.: |
| 1576 | r = "Moved Permanently"; |
| 1577 | break; |
| 1578 | case HTTP_STATUS_FOUNDcxx . . $ HTTP_STATUS_FOUND.: |
| 1579 | r = "Found"; |
| 1580 | break; |
| 1581 | case HTTP_STATUS_SEE_OTHERcxx . . $ HTTP_STATUS_SEE_OTHER.: |
| 1582 | r = "See Other"; |
| 1583 | break; |
| 1584 | case HTTP_STATUS_NOT_MODIFIEDcxx . . $ HTTP_STATUS_NOT_MODIFIED.: |
| 1585 | r = "Not Modified"; |
| 1586 | break; |
| 1587 | case HTTP_STATUS_USE_PROXYcxx . . $ HTTP_STATUS_USE_PROXY.: |
| 1588 | r = "Use Proxy"; |
| 1589 | break; |
| 1590 | case HTTP_STATUS_TEMPORARY_REDIRECTcxx . . $ HTTP_STATUS_TEMPORARY_REDIRECT.: |
| 1591 | r = "Temporary Redirect"; |
| 1592 | break; |
| 1593 | case HTTP_STATUS_BAD_REQUESTcxx . . $ HTTP_STATUS_BAD_REQUEST.: |
| 1594 | r = "Bad Request"; |
| 1595 | break; |
| 1596 | case HTTP_STATUS_UNAUTHORIZEDcxx . . $ HTTP_STATUS_UNAUTHORIZED.: |
| 1597 | r = "Unauthorized"; |
| 1598 | break; |
| 1599 | case HTTP_STATUS_PAYMENT_REQUIREDcxx . . $ HTTP_STATUS_PAYMENT_REQUIRED.: |
| 1600 | r = "Payment Required"; |
| 1601 | break; |
| 1602 | case HTTP_STATUS_FORBIDDENcxx . . $ HTTP_STATUS_FORBIDDEN.: |
| 1603 | r = "Forbidden"; |
| 1604 | break; |
| 1605 | case HTTP_STATUS_NOT_FOUNDcxx . . $ HTTP_STATUS_NOT_FOUND.: |
| 1606 | r = "Not Found"; |
| 1607 | break; |
| 1608 | case HTTP_STATUS_METHOD_NOT_ALLOWEDcxx . . $ HTTP_STATUS_METHOD_NOT_ALLOWED.: |
| 1609 | r = "Method Not Allowed"; |
| 1610 | break; |
| 1611 | case HTTP_STATUS_NOT_ACCEPTABLEcxx . . $ HTTP_STATUS_NOT_ACCEPTABLE.: |
| 1612 | r = "Not Acceptable"; |
| 1613 | break; |
| 1614 | case HTTP_STATUS_PROXY_AUTH_REQUIREDcxx . . $ HTTP_STATUS_PROXY_AUTH_REQUIRED.: |
| 1615 | r = "Proxy Authentication Required"; |
| 1616 | break; |
| 1617 | case HTTP_STATUS_REQUEST_TIMEOUTcxx . . $ HTTP_STATUS_REQUEST_TIMEOUT.: |
| 1618 | r = "Request Time-out"; |
| 1619 | break; |
| 1620 | case HTTP_STATUS_CONFLICTcxx . . $ HTTP_STATUS_CONFLICT.: |
| 1621 | r = "Conflict"; |
| 1622 | break; |
| 1623 | case HTTP_STATUS_GONEcxx . . $ HTTP_STATUS_GONE.: |
| 1624 | r = "Gone"; |
| 1625 | break; |
| 1626 | case HTTP_STATUS_LENGTH_REQUIREDcxx . . $ HTTP_STATUS_LENGTH_REQUIRED.: |
| 1627 | r = "Length Required"; |
| 1628 | break; |
| 1629 | case HTTP_STATUS_PRECONDITION_FAILEDcxx . . $ HTTP_STATUS_PRECONDITION_FAILED.: |
| 1630 | r = "Precondition Failed"; |
| 1631 | break; |
| 1632 | case HTTP_STATUS_REQUEST_ENTITY_TOO_LARGEcxx . . $ HTTP_STATUS_REQUEST_ENTITY_TOO_LARGE.: |
| 1633 | r = "Request Entity Too Large"; |
| 1634 | break; |
| 1635 | case HTTP_STATUS_REQUEST_URI_TOO_LARGEcxx . . $ HTTP_STATUS_REQUEST_URI_TOO_LARGE.: |
| 1636 | r = "Request-URI Too Large"; |
| 1637 | break; |
| 1638 | case HTTP_STATUS_UNSUPPORTED_MEDIA_TYPEcxx . . $ HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE.: |
| 1639 | r = "Unsupported Media Type"; |
| 1640 | break; |
| 1641 | case HTTP_STATUS_REQUEST_RANGE_INVALIDcxx . . $ HTTP_STATUS_REQUEST_RANGE_INVALID.: |
| 1642 | r = "Requested range not satisfiable"; |
| 1643 | break; |
| 1644 | case HTTP_STATUS_EXPECTATION_FAILEDcxx . . $ HTTP_STATUS_EXPECTATION_FAILED.: |
| 1645 | r = "Expectation Failed"; |
| 1646 | break; |
| 1647 | case HTTP_STATUS_MISDIRECTED_REQUESTcxx . . $ HTTP_STATUS_MISDIRECTED_REQUEST.: |
| 1648 | r = "Misdirected Request"; |
| 1649 | break; |
| 1650 | case HTTP_STATUS_INTERNAL_ERRORcxx . . $ HTTP_STATUS_INTERNAL_ERROR.: |
| 1651 | r = "Internal Server Error"; |
| 1652 | break; |
| 1653 | case HTTP_STATUS_NOT_IMPLEMENTEDcxx . . $ HTTP_STATUS_NOT_IMPLEMENTED.: |
| 1654 | r = "Not Implemented"; |
| 1655 | break; |
| 1656 | case HTTP_STATUS_BAD_GATEWAYcxx . . $ HTTP_STATUS_BAD_GATEWAY.: |
| 1657 | r = "Bad Gateway"; |
| 1658 | break; |
| 1659 | case HTTP_STATUS_SERVICE_UNAVAILABLEcxx . . $ HTTP_STATUS_SERVICE_UNAVAILABLE.: |
| 1660 | r = "Service Unavailable"; |
| 1661 | break; |
| 1662 | case HTTP_STATUS_GATEWAY_TIMEOUTcxx . . $ HTTP_STATUS_GATEWAY_TIMEOUT.: |
| 1663 | r = "Gateway Time-out"; |
| 1664 | break; |
| 1665 | case HTTP_STATUS_BAD_VERSIONcxx . . $ HTTP_STATUS_BAD_VERSION.: |
| 1666 | r = "HTTP Version not supported"; |
| 1667 | break; |
| 1668 | default: |
| 1669 | r = ""; |
| 1670 | break; |
| 1671 | } |
| 1672 | |
| 1673 | return (r); |
| 1674 | } |
| 1675 | |
| 1676 | const char * |
| 1677 | http_method_textcxx . . $ http_method_text(f7ae7e56280f18ae).(int method) |
| 1678 | { |
| 1679 | char *r; |
| 1680 | |
| 1681 | switch(method) { |
| 1682 | case HTTP_METHOD_GETcxx . . $ `include/kore/http.h:229:9`!: |
| 1683 | r = "GET"; |
| 1684 | break; |
| 1685 | case HTTP_METHOD_POSTcxx . . $ `include/kore/http.h:230:9`!: |
| 1686 | r = "POST"; |
| 1687 | break; |
| 1688 | case HTTP_METHOD_PUTcxx . . $ `include/kore/http.h:231:9`!: |
| 1689 | r = "PUT"; |
| 1690 | break; |
| 1691 | case HTTP_METHOD_DELETEcxx . . $ `include/kore/http.h:232:9`!: |
| 1692 | r = "DELETE"; |
| 1693 | break; |
| 1694 | case HTTP_METHOD_HEADcxx . . $ `include/kore/http.h:233:9`!: |
| 1695 | r = "HEAD"; |
| 1696 | break; |
| 1697 | case HTTP_METHOD_OPTIONScxx . . $ `include/kore/http.h:234:9`!: |
| 1698 | r = "OPTIONS"; |
| 1699 | break; |
| 1700 | case HTTP_METHOD_PATCHcxx . . $ `include/kore/http.h:235:9`!: |
| 1701 | r = "PATCH"; |
| 1702 | break; |
| 1703 | default: |
| 1704 | r = ""; |
| 1705 | break; |
| 1706 | } |
| 1707 | |
| 1708 | return (r); |
| 1709 | } |
| 1710 | |
| 1711 | int |
| 1712 | http_method_valuecxx . . $ http_method_value(5c4306d8553b3696).(const char *method) |
| 1713 | { |
| 1714 | if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(method, "GET")) |
| 1715 | return (HTTP_METHOD_GETcxx . . $ `include/kore/http.h:229:9`!); |
| 1716 | |
| 1717 | if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(method, "POST")) |
| 1718 | return (HTTP_METHOD_POSTcxx . . $ `include/kore/http.h:230:9`!); |
| 1719 | |
| 1720 | if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(method, "PUT")) |
| 1721 | return (HTTP_METHOD_PUTcxx . . $ `include/kore/http.h:231:9`!); |
| 1722 | |
| 1723 | if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(method, "DELETE")) |
| 1724 | return (HTTP_METHOD_DELETEcxx . . $ `include/kore/http.h:232:9`!); |
| 1725 | |
| 1726 | if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(method, "HEAD")) |
| 1727 | return (HTTP_METHOD_HEADcxx . . $ `include/kore/http.h:233:9`!); |
| 1728 | |
| 1729 | if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(method, "OPTIONS")) |
| 1730 | return (HTTP_METHOD_OPTIONScxx . . $ `include/kore/http.h:234:9`!); |
| 1731 | |
| 1732 | if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(method, "PATCH")) |
| 1733 | return (HTTP_METHOD_PATCHcxx . . $ `include/kore/http.h:235:9`!); |
| 1734 | |
| 1735 | return (0); |
| 1736 | } |
| 1737 | |
| 1738 | int |
| 1739 | http_media_registercxx . . $ http_media_register(5ae29d726ae57f88).(const char *ext, const char *type) |
| 1740 | { |
| 1741 | struct http_media_typecxx . . $ http_media_type# *media; |
| 1742 | |
| 1743 | LIST_FOREACHcxx . . $ `<external>/2546723208511035544/queue.h:134:9`!(media, &http_media_types, list) { |
| 1744 | if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(media->extcxx . . $ http_media_type#ext., ext)) |
| 1745 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 1746 | } |
| 1747 | |
| 1748 | media = kore_calloccxx . . $ kore_calloc(63a7bf2941bfcd7a).(1, sizeof(*media)); |
| 1749 | media->extcxx . . $ http_media_type#ext. = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(ext); |
| 1750 | media->typecxx . . $ http_media_type#type. = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(type); |
| 1751 | |
| 1752 | LIST_INSERT_HEADcxx . . $ `<external>/2546723208511035544/queue.h:120:9`!(&http_media_types, media, list); |
| 1753 | |
| 1754 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 1755 | } |
| 1756 | |
| 1757 | const char * |
| 1758 | http_media_typecxx . . $ http_media_type(fb58d2e09a2a1ce6).(const char *path) |
| 1759 | { |
| 1760 | const char *p; |
| 1761 | struct http_media_typecxx . . $ http_media_type# *media; |
| 1762 | |
| 1763 | if ((p = strrchrcxx . . $ strrchr(2050848944e00d54).(path, '.')) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1764 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1765 | |
| 1766 | p++; |
| 1767 | if (*p == '\0') |
| 1768 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1769 | |
| 1770 | LIST_FOREACHcxx . . $ `<external>/2546723208511035544/queue.h:134:9`!(media, &http_media_types, list) { |
| 1771 | if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(media->extcxx . . $ http_media_type#ext., p)) |
| 1772 | return (media->typecxx . . $ http_media_type#type.); |
| 1773 | } |
| 1774 | |
| 1775 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1776 | } |
| 1777 | |
| 1778 | char * |
| 1779 | http_validate_headercxx . . $ http_validate_header(7a9722d75b371431).(char *header) |
| 1780 | { |
| 1781 | u_int8_tcxx . . $ u_int8_t# idx; |
| 1782 | char *p, *value; |
| 1783 | |
| 1784 | for (p = header; *p != '\0'; p++) { |
| 1785 | idx = *p; |
| 1786 | if (idx > HTTP_MAP_LIMITcxx . . $ `src/http.c:69:9`!) |
| 1787 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1788 | |
| 1789 | if (*p == ':') { |
| 1790 | *(p)++ = '\0'; |
| 1791 | break; |
| 1792 | } |
| 1793 | |
| 1794 | if (http_tokencxx . . $ http_token.[idx] == 0x00) |
| 1795 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1796 | } |
| 1797 | |
| 1798 | while (isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*(unsigned char *)p)) |
| 1799 | p++; |
| 1800 | |
| 1801 | if (*p == '\0') |
| 1802 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1803 | |
| 1804 | value = p; |
| 1805 | while (*p != '\0') { |
| 1806 | idx = *p; |
| 1807 | if (idx > HTTP_MAP_LIMITcxx . . $ `src/http.c:69:9`!) |
| 1808 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1809 | if (http_field_contentcxx . . $ http_field_content.[idx] == 0x00) |
| 1810 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1811 | p++; |
| 1812 | } |
| 1813 | |
| 1814 | return (value); |
| 1815 | } |
| 1816 | |
| 1817 | static int |
| 1818 | http_release_buffercxx . . $ http_release_buffer(82c4d452dc2a871a).(struct netbufcxx . . $ netbuf# *nb) |
| 1819 | { |
| 1820 | kore_buf_freecxx . . $ kore_buf_free(2648f45d13d14762).(nb->extracxx . . $ netbuf#extra.); |
| 1821 | |
| 1822 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 1823 | } |
| 1824 | |
| 1825 | static int |
| 1826 | http_check_redirectcxx . . $ http_check_redirect(83d71fa0c26d908b).(struct http_requestcxx . . $ http_request# *req, struct kore_domaincxx . . $ kore_domain# *dom) |
| 1827 | { |
| 1828 | int idx; |
| 1829 | struct http_redirectcxx . . $ http_redirect# *rdr; |
| 1830 | const char *uri; |
| 1831 | char key[4]; |
| 1832 | struct kore_bufcxx . . $ kore_buf# location; |
| 1833 | |
| 1834 | TAILQ_FOREACHcxx . . $ `<external>/2546723208511035544/queue.h:435:9`!(rdr, &dom->redirects, list) { |
| 1835 | if (!regexeccxx . . $ regexec(7b724a18a85d26ac).(&(rdr->rctxcxx . . $ http_redirect#rctx.), req->pathcxx . . $ http_request#path., |
| 1836 | HTTP_CAPTURE_GROUPScxx . . $ `include/kore/http.h:257:9`!, req->cgroupscxx . . $ http_request#cgroups., 0)) |
| 1837 | break; |
| 1838 | } |
| 1839 | |
| 1840 | if (rdr == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1841 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 1842 | |
| 1843 | uri = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1844 | kore_buf_initcxx . . $ kore_buf_init(bd90e0817a56138f).(&location, 128); |
| 1845 | |
| 1846 | if (rdr->targetcxx . . $ http_redirect#target.) { |
| 1847 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(&location, "%s", rdr->targetcxx . . $ http_redirect#target.); |
| 1848 | |
| 1849 | if (req->query_stringcxx . . $ http_request#query_string. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1850 | kore_buf_replace_stringcxx . . $ kore_buf_replace_string(8008de6d84fb5eac).(&location, "$qs", |
| 1851 | req->query_stringcxx . . $ http_request#query_string., strlencxx . . $ strlen(751346f8406fd082).(req->query_stringcxx . . $ http_request#query_string.)); |
| 1852 | } |
| 1853 | |
| 1854 | /* Starts at 1 to skip the full path. */ |
| 1855 | for (idx = 1; idx < HTTP_CAPTURE_GROUPScxx . . $ `include/kore/http.h:257:9`! - 1; idx++) { |
| 1856 | if (req->cgroupscxx . . $ http_request#cgroups.[idx].rm_socxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_so. == -1 || |
| 1857 | req->cgroupscxx . . $ http_request#cgroups.[idx].rm_eocxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_eo. == -1) |
| 1858 | break; |
| 1859 | |
| 1860 | (void)snprintfcxx . . $ snprintf(ea502d73e74c754c).(key, sizeof(key), "$%d", idx); |
| 1861 | |
| 1862 | kore_buf_replace_stringcxx . . $ kore_buf_replace_string(8008de6d84fb5eac).(&location, key, |
| 1863 | req->pathcxx . . $ http_request#path. + req->cgroupscxx . . $ http_request#cgroups.[idx].rm_socxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_so., |
| 1864 | req->cgroupscxx . . $ http_request#cgroups.[idx].rm_eocxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_eo. - req->cgroupscxx . . $ http_request#cgroups.[idx].rm_socxx . . $ $anonymous_type_2410a2af4c2f900a_1#rm_so.); |
| 1865 | } |
| 1866 | |
| 1867 | uri = kore_buf_stringifycxx . . $ kore_buf_stringify(4bc5b263e10e2f7b).(&location, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1868 | } |
| 1869 | |
| 1870 | if (uri) |
| 1871 | http_response_headercxx . . $ http_response_header(84119343264ef6a5).(req, "location", uri); |
| 1872 | |
| 1873 | http_responsecxx . . $ http_response(8f2daeb0fc6e2740).(req, rdr->statuscxx . . $ http_redirect#status., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0); |
| 1874 | kore_buf_cleanupcxx . . $ kore_buf_cleanup(2648f45d13d14762).(&location); |
| 1875 | |
| 1876 | if (dom->accesslogcxx . . $ kore_domain#accesslog.) |
| 1877 | kore_accesslogcxx . . $ kore_accesslog(322c51a23f687f95).(req); |
| 1878 | |
| 1879 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 1880 | } |
| 1881 | |
| 1882 | static struct http_requestcxx . . $ http_request# * |
| 1883 | http_request_newcxx . . $ http_request_new(f7dd24d21b927557).(struct connectioncxx . . $ connection# *c, const char *host, |
| 1884 | const char *method, char *path, const char *version) |
| 1885 | { |
| 1886 | struct kore_domaincxx . . $ kore_domain# *dom; |
| 1887 | struct http_requestcxx . . $ http_request# *req; |
| 1888 | size_t qsoff; |
| 1889 | char *p, *hp; |
| 1890 | int m, flags, exists; |
| 1891 | |
| 1892 | if (http_request_countcxx . . $ http_request_count. >= http_request_limitcxx . . $ http_request_limit.) { |
| 1893 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_SERVICE_UNAVAILABLEcxx . . $ HTTP_STATUS_SERVICE_UNAVAILABLE.); |
| 1894 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1895 | } |
| 1896 | |
| 1897 | if (strlencxx . . $ strlen(751346f8406fd082).(host) >= KORE_DOMAINNAME_LENcxx . . $ `include/kore/kore.h:102:9`! - 1) { |
| 1898 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_BAD_REQUESTcxx . . $ HTTP_STATUS_BAD_REQUEST.); |
| 1899 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1900 | } |
| 1901 | |
| 1902 | if (strlencxx . . $ strlen(751346f8406fd082).(path) >= HTTP_URI_LENcxx . . $ `include/kore/http.h:38:9`! - 1) { |
| 1903 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_REQUEST_URI_TOO_LARGEcxx . . $ HTTP_STATUS_REQUEST_URI_TOO_LARGE.); |
| 1904 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1905 | } |
| 1906 | |
| 1907 | if (strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(version, "http/1.1")) { |
| 1908 | if (strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(version, "http/1.0")) { |
| 1909 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_BAD_VERSIONcxx . . $ HTTP_STATUS_BAD_VERSION.); |
| 1910 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1911 | } |
| 1912 | |
| 1913 | flags = HTTP_VERSION_1_0cxx . . $ `include/kore/http.h:250:9`!; |
| 1914 | } else { |
| 1915 | flags = HTTP_VERSION_1_1cxx . . $ `include/kore/http.h:249:9`!; |
| 1916 | } |
| 1917 | |
| 1918 | if ((p = strchrcxx . . $ strchr(2050848944e00d54).(path, '?')) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1919 | qsoff = p - path; |
| 1920 | } else { |
| 1921 | qsoff = 0; |
| 1922 | } |
| 1923 | |
| 1924 | hp = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1925 | |
| 1926 | switch (c->familycxx . . $ connection#family.) { |
| 1927 | case AF_INET6cxx . . $ `<external>/8962547315054503424/socket.h:105:9`!: |
| 1928 | if (*host == '[') { |
| 1929 | if ((hp = strrchrcxx . . $ strrchr(2050848944e00d54).(host, ']')) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1930 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_BAD_REQUESTcxx . . $ HTTP_STATUS_BAD_REQUEST.); |
| 1931 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1932 | } |
| 1933 | hp++; |
| 1934 | if (*hp == ':') |
| 1935 | *hp = '\0'; |
| 1936 | else |
| 1937 | hp = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 1938 | } |
| 1939 | break; |
| 1940 | default: |
| 1941 | if ((hp = strrchrcxx . . $ strrchr(2050848944e00d54).(host, ':')) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1942 | *hp = '\0'; |
| 1943 | break; |
| 1944 | } |
| 1945 | |
| 1946 | if (c->ownercxx . . $ connection#owner.->servercxx . . $ listener#server.->tlscxx . . $ kore_server#tls. && c->tls_snicxx . . $ connection#tls_sni. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1947 | if (strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(c->tls_snicxx . . $ connection#tls_sni., host)) { |
| 1948 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_MISDIRECTED_REQUESTcxx . . $ HTTP_STATUS_MISDIRECTED_REQUEST.); |
| 1949 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1950 | } |
| 1951 | } |
| 1952 | |
| 1953 | if ((dom = kore_domain_lookupcxx . . $ kore_domain_lookup(1312d99c9b0d5185).(c->ownercxx . . $ connection#owner.->servercxx . . $ listener#server., host)) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1954 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_NOT_FOUNDcxx . . $ HTTP_STATUS_NOT_FOUND.); |
| 1955 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1956 | } |
| 1957 | |
| 1958 | if (dom->cafilecxx . . $ kore_domain#cafile. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && c->tls_certcxx . . $ connection#tls_cert. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 1959 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_FORBIDDENcxx . . $ HTTP_STATUS_FORBIDDEN.); |
| 1960 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1961 | } |
| 1962 | |
| 1963 | if (hp != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 1964 | *hp = ':'; |
| 1965 | |
| 1966 | if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(method, "get")) { |
| 1967 | m = HTTP_METHOD_GETcxx . . $ `include/kore/http.h:229:9`!; |
| 1968 | flags |= HTTP_REQUEST_COMPLETEcxx . . $ `include/kore/http.h:241:9`!; |
| 1969 | } else if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(method, "delete")) { |
| 1970 | m = HTTP_METHOD_DELETEcxx . . $ `include/kore/http.h:232:9`!; |
| 1971 | flags |= HTTP_REQUEST_EXPECT_BODYcxx . . $ `include/kore/http.h:244:9`!; |
| 1972 | } else if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(method, "post")) { |
| 1973 | m = HTTP_METHOD_POSTcxx . . $ `include/kore/http.h:230:9`!; |
| 1974 | flags |= HTTP_REQUEST_EXPECT_BODYcxx . . $ `include/kore/http.h:244:9`!; |
| 1975 | } else if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(method, "put")) { |
| 1976 | m = HTTP_METHOD_PUTcxx . . $ `include/kore/http.h:231:9`!; |
| 1977 | flags |= HTTP_REQUEST_EXPECT_BODYcxx . . $ `include/kore/http.h:244:9`!; |
| 1978 | } else if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(method, "head")) { |
| 1979 | m = HTTP_METHOD_HEADcxx . . $ `include/kore/http.h:233:9`!; |
| 1980 | flags |= HTTP_REQUEST_COMPLETEcxx . . $ `include/kore/http.h:241:9`!; |
| 1981 | } else if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(method, "options")) { |
| 1982 | m = HTTP_METHOD_OPTIONScxx . . $ `include/kore/http.h:234:9`!; |
| 1983 | flags |= HTTP_REQUEST_COMPLETEcxx . . $ `include/kore/http.h:241:9`!; |
| 1984 | } else if (!strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(method, "patch")) { |
| 1985 | m = HTTP_METHOD_PATCHcxx . . $ `include/kore/http.h:235:9`!; |
| 1986 | flags |= HTTP_REQUEST_EXPECT_BODYcxx . . $ `include/kore/http.h:244:9`!; |
| 1987 | } else { |
| 1988 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_BAD_REQUESTcxx . . $ HTTP_STATUS_BAD_REQUEST.); |
| 1989 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1990 | } |
| 1991 | |
| 1992 | if (flags & HTTP_VERSION_1_0cxx . . $ `include/kore/http.h:250:9`!) { |
| 1993 | if (m != HTTP_METHOD_GETcxx . . $ `include/kore/http.h:229:9`! && m != HTTP_METHOD_POSTcxx . . $ `include/kore/http.h:230:9`! && |
| 1994 | m != HTTP_METHOD_HEADcxx . . $ `include/kore/http.h:233:9`!) { |
| 1995 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_METHOD_NOT_ALLOWEDcxx . . $ HTTP_STATUS_METHOD_NOT_ALLOWED.); |
| 1996 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 1997 | } |
| 1998 | } |
| 1999 | |
| 2000 | req = kore_pool_getcxx . . $ kore_pool_get(f5c578167d321b17).(&http_request_poolcxx . . $ http_request_pool.); |
| 2001 | |
| 2002 | req->endcxx . . $ http_request#end. = 0; |
| 2003 | req->totalcxx . . $ http_request#total. = 0; |
| 2004 | req->startcxx . . $ http_request#start. = 0; |
| 2005 | req->ownercxx . . $ http_request#owner. = c; |
| 2006 | req->statuscxx . . $ http_request#status. = 0; |
| 2007 | req->methodcxx . . $ http_request#method. = m; |
| 2008 | req->agentcxx . . $ http_request#agent. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2009 | req->referercxx . . $ http_request#referer. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2010 | req->runlockcxx . . $ http_request#runlock. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2011 | req->flagscxx . . $ http_request#flags. = flags; |
| 2012 | req->fsm_statecxx . . $ http_request#fsm_state. = 0; |
| 2013 | req->http_bodycxx . . $ http_request#http_body. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2014 | req->http_body_fdcxx . . $ http_request#http_body_fd. = -1; |
| 2015 | req->hdlr_extracxx . . $ http_request#hdlr_extra. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2016 | req->content_lengthcxx . . $ http_request#content_length. = 0; |
| 2017 | req->query_stringcxx . . $ http_request#query_string. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2018 | req->http_body_lengthcxx . . $ http_request#http_body_length. = 0; |
| 2019 | req->http_body_offsetcxx . . $ http_request#http_body_offset. = 0; |
| 2020 | req->http_body_pathcxx . . $ http_request#http_body_path. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2021 | |
| 2022 | req->hostcxx . . $ http_request#host. = host; |
| 2023 | req->pathcxx . . $ http_request#path. = path; |
| 2024 | |
| 2025 | #if defined(KORE_USE_PYTHON) |
| 2026 | req->py_req = NULL; |
| 2027 | req->py_coro = NULL; |
| 2028 | req->py_rqnext = NULL; |
| 2029 | req->py_validator = NULL; |
| 2030 | #endif |
| 2031 | |
| 2032 | if (qsoff > 0) { |
| 2033 | req->query_stringcxx . . $ http_request#query_string. = path + qsoff; |
| 2034 | *(req->query_stringcxx . . $ http_request#query_string.)++ = '\0'; |
| 2035 | } else { |
| 2036 | req->query_stringcxx . . $ http_request#query_string. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2037 | } |
| 2038 | |
| 2039 | /* Checked further down below if we need to 404. */ |
| 2040 | exists = kore_route_lookupcxx . . $ kore_route_lookup(975f4cf35c41ba06).(req, dom, m, &req->rtcxx . . $ http_request#rt.); |
| 2041 | |
| 2042 | TAILQ_INITcxx . . $ `<external>/2546723208511035544/queue.h:387:9`!(&(req->resp_headers)); |
| 2043 | TAILQ_INITcxx . . $ `<external>/2546723208511035544/queue.h:387:9`!(&(req->req_headers)); |
| 2044 | TAILQ_INITcxx . . $ `<external>/2546723208511035544/queue.h:387:9`!(&(req->resp_cookies)); |
| 2045 | TAILQ_INITcxx . . $ `<external>/2546723208511035544/queue.h:387:9`!(&(req->req_cookies)); |
| 2046 | TAILQ_INITcxx . . $ `<external>/2546723208511035544/queue.h:387:9`!(&(req->arguments)); |
| 2047 | TAILQ_INITcxx . . $ `<external>/2546723208511035544/queue.h:387:9`!(&(req->files)); |
| 2048 | |
| 2049 | #if defined(KORE_USE_TASKS) |
| 2050 | LIST_INIT(&(req->tasks)); |
| 2051 | #endif |
| 2052 | |
| 2053 | #if defined(KORE_USE_PGSQL) |
| 2054 | LIST_INIT(&(req->pgsqls)); |
| 2055 | #endif |
| 2056 | |
| 2057 | http_request_countcxx . . $ http_request_count.++; |
| 2058 | TAILQ_INSERT_HEADcxx . . $ `<external>/2546723208511035544/queue.h:392:9`!(&http_requests, req, list); |
| 2059 | TAILQ_INSERT_TAILcxx . . $ `<external>/2546723208511035544/queue.h:402:9`!(&(c->http_requests), req, olist); |
| 2060 | |
| 2061 | if (http_check_redirectcxx . . $ http_check_redirect(83d71fa0c26d908b).(req, dom)) { |
| 2062 | http_request_freecxx . . $ http_request_free(322c51a23f687f95).(req); |
| 2063 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 2064 | } |
| 2065 | |
| 2066 | if (exists == 0) { |
| 2067 | http_request_freecxx . . $ http_request_free(322c51a23f687f95).(req); |
| 2068 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_NOT_FOUNDcxx . . $ HTTP_STATUS_NOT_FOUND.); |
| 2069 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 2070 | } |
| 2071 | |
| 2072 | if (req->rtcxx . . $ http_request#rt. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 2073 | http_request_freecxx . . $ http_request_free(322c51a23f687f95).(req); |
| 2074 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(c, HTTP_STATUS_METHOD_NOT_ALLOWEDcxx . . $ HTTP_STATUS_METHOD_NOT_ALLOWED.); |
| 2075 | return (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 2076 | } |
| 2077 | |
| 2078 | return (req); |
| 2079 | } |
| 2080 | |
| 2081 | static int |
| 2082 | multipart_find_datacxx . . $ multipart_find_data(30566873e75e1a09).(struct kore_bufcxx . . $ kore_buf# *in, struct kore_bufcxx . . $ kore_buf# *out, |
| 2083 | size_t *olen, struct http_requestcxx . . $ http_request# *req, const void *needle, size_t len) |
| 2084 | { |
| 2085 | ssize_tcxx . . $ ssize_t# ret; |
| 2086 | size_t left; |
| 2087 | u_int8_tcxx . . $ u_int8_t# *p, first, data[4096]; |
| 2088 | |
| 2089 | if (olen != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2090 | *olen = 0; |
| 2091 | |
| 2092 | first = *(const u_int8_tcxx . . $ u_int8_t# *)needle; |
| 2093 | for (;;) { |
| 2094 | if (in->offsetcxx . . $ kore_buf#offset. < len) { |
| 2095 | ret = http_body_readcxx . . $ http_body_read(da9cfe03a73e7462).(req, data, sizeof(data)); |
| 2096 | if (ret == -1) |
| 2097 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 2098 | if (ret == 0) |
| 2099 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 2100 | |
| 2101 | kore_buf_appendcxx . . $ kore_buf_append(4909ebf68ec24f4d).(in, data, ret); |
| 2102 | continue; |
| 2103 | } |
| 2104 | |
| 2105 | p = kore_mem_findcxx . . $ kore_mem_find(d6408e6ff8ad1a7e).(in->datacxx . . $ kore_buf#data., in->offsetcxx . . $ kore_buf#offset., &first, 1); |
| 2106 | if (p == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 2107 | if (out != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2108 | kore_buf_appendcxx . . $ kore_buf_append(4909ebf68ec24f4d).(out, in->datacxx . . $ kore_buf#data., in->offsetcxx . . $ kore_buf#offset.); |
| 2109 | if (olen != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2110 | *olen += in->offsetcxx . . $ kore_buf#offset.; |
| 2111 | kore_buf_resetcxx . . $ kore_buf_reset(2648f45d13d14762).(in); |
| 2112 | continue; |
| 2113 | } |
| 2114 | |
| 2115 | left = in->offsetcxx . . $ kore_buf#offset. - (p - in->datacxx . . $ kore_buf#data.); |
| 2116 | if (left < len) { |
| 2117 | if (out != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2118 | kore_buf_appendcxx . . $ kore_buf_append(4909ebf68ec24f4d).(out, in->datacxx . . $ kore_buf#data., (p - in->datacxx . . $ kore_buf#data.)); |
| 2119 | if (olen != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2120 | *olen += (p - in->datacxx . . $ kore_buf#data.); |
| 2121 | memmovecxx . . $ memmove(cc817cb175f282d).(in->datacxx . . $ kore_buf#data., p, left); |
| 2122 | in->offsetcxx . . $ kore_buf#offset. = left; |
| 2123 | continue; |
| 2124 | } |
| 2125 | |
| 2126 | if (!memcmpcxx . . $ memcmp(36f949851efa3055).(p, needle, len)) { |
| 2127 | if (out != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2128 | kore_buf_appendcxx . . $ kore_buf_append(4909ebf68ec24f4d).(out, in->datacxx . . $ kore_buf#data., p - in->datacxx . . $ kore_buf#data.); |
| 2129 | if (olen != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2130 | *olen += (p - in->datacxx . . $ kore_buf#data.); |
| 2131 | |
| 2132 | in->offsetcxx . . $ kore_buf#offset. = left - len; |
| 2133 | if (in->offsetcxx . . $ kore_buf#offset. > 0) |
| 2134 | memmovecxx . . $ memmove(cc817cb175f282d).(in->datacxx . . $ kore_buf#data., p + len, in->offsetcxx . . $ kore_buf#offset.); |
| 2135 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 2136 | } |
| 2137 | |
| 2138 | if (out != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2139 | kore_buf_appendcxx . . $ kore_buf_append(4909ebf68ec24f4d).(out, in->datacxx . . $ kore_buf#data., (p - in->datacxx . . $ kore_buf#data.) + 1); |
| 2140 | if (olen != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2141 | *olen += (p - in->datacxx . . $ kore_buf#data.) + 1; |
| 2142 | |
| 2143 | in->offsetcxx . . $ kore_buf#offset. = left - 1; |
| 2144 | if (in->offsetcxx . . $ kore_buf#offset. > 0) |
| 2145 | memmovecxx . . $ memmove(cc817cb175f282d).(in->datacxx . . $ kore_buf#data., p + 1, in->offsetcxx . . $ kore_buf#offset.); |
| 2146 | } |
| 2147 | |
| 2148 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 2149 | } |
| 2150 | |
| 2151 | static int |
| 2152 | multipart_parse_headerscxx . . $ multipart_parse_headers(76feff133a1f576a).(struct http_requestcxx . . $ http_request# *req, struct kore_bufcxx . . $ kore_buf# *in, |
| 2153 | struct kore_bufcxx . . $ kore_buf# *hbuf, const char *boundary, const int blen) |
| 2154 | { |
| 2155 | int h, c, i; |
| 2156 | char *headers[5], *args[5], *opt[5]; |
| 2157 | char *d, *val, *name, *fname, *string; |
| 2158 | |
| 2159 | string = kore_buf_stringifycxx . . $ kore_buf_stringify(4bc5b263e10e2f7b).(hbuf, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 2160 | h = kore_split_stringcxx . . $ kore_split_string(87b756e43bd5489c).(string, "\r\n", headers, 5); |
| 2161 | for (i = 0; i < h; i++) { |
| 2162 | c = kore_split_stringcxx . . $ kore_split_string(87b756e43bd5489c).(headers[i], ":", args, 5); |
| 2163 | if (c != 2) |
| 2164 | continue; |
| 2165 | |
| 2166 | /* Ignore other headers for now. */ |
| 2167 | if (strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(args[0], "content-disposition")) |
| 2168 | continue; |
| 2169 | |
| 2170 | for (d = args[1]; isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*(unsigned char *)d); d++) |
| 2171 | ; |
| 2172 | |
| 2173 | c = kore_split_stringcxx . . $ kore_split_string(87b756e43bd5489c).(d, ";", opt, 5); |
| 2174 | if (c < 2) |
| 2175 | continue; |
| 2176 | |
| 2177 | if (strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(opt[0], "form-data")) |
| 2178 | continue; |
| 2179 | |
| 2180 | if ((val = strchrcxx . . $ strchr(2050848944e00d54).(opt[1], '=')) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2181 | continue; |
| 2182 | if (strlencxx . . $ strlen(751346f8406fd082).(val) < 3) |
| 2183 | continue; |
| 2184 | |
| 2185 | val++; |
| 2186 | kore_strip_charscxx . . $ kore_strip_chars(28f0fb8875227cc8).(val, '"', &name); |
| 2187 | |
| 2188 | if (opt[2] == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 2189 | multipart_add_fieldcxx . . $ multipart_add_field(846663990203301b).(req, in, name, boundary, blen); |
| 2190 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(name); |
| 2191 | continue; |
| 2192 | } |
| 2193 | |
| 2194 | for (d = opt[2]; isspacecxx . . $ `<external>/17904084882347303253/ctype.h:197:10`!(*(unsigned char *)d); d++) |
| 2195 | ; |
| 2196 | |
| 2197 | if (!strncasecmpcxx . . $ strncasecmp(fd278af2f295fa2e).(d, "filename=", 9)) { |
| 2198 | if ((val = strchrcxx . . $ strchr(2050848944e00d54).(d, '=')) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 2199 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(name); |
| 2200 | continue; |
| 2201 | } |
| 2202 | |
| 2203 | val++; |
| 2204 | kore_strip_charscxx . . $ kore_strip_chars(28f0fb8875227cc8).(val, '"', &fname); |
| 2205 | if (strlencxx . . $ strlen(751346f8406fd082).(fname) > 0) { |
| 2206 | multipart_file_addcxx . . $ multipart_file_add(3722bdda08777045).(req, |
| 2207 | in, name, fname, boundary, blen); |
| 2208 | } |
| 2209 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(fname); |
| 2210 | } |
| 2211 | |
| 2212 | kore_freecxx . . $ kore_free(5d22bdacc48458e8).(name); |
| 2213 | } |
| 2214 | |
| 2215 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 2216 | } |
| 2217 | |
| 2218 | static void |
| 2219 | multipart_add_fieldcxx . . $ multipart_add_field(846663990203301b).(struct http_requestcxx . . $ http_request# *req, struct kore_bufcxx . . $ kore_buf# *in, |
| 2220 | char *name, const char *boundary, const int blen) |
| 2221 | { |
| 2222 | struct kore_bufcxx . . $ kore_buf# *data; |
| 2223 | char *string; |
| 2224 | |
| 2225 | data = kore_buf_alloccxx . . $ kore_buf_alloc(ae982dcc82edde78).(128); |
| 2226 | |
| 2227 | if (!multipart_find_datacxx . . $ multipart_find_data(30566873e75e1a09).(in, data, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, req, boundary, blen)) { |
| 2228 | kore_buf_freecxx . . $ kore_buf_free(2648f45d13d14762).(data); |
| 2229 | return; |
| 2230 | } |
| 2231 | |
| 2232 | if (data->offsetcxx . . $ kore_buf#offset. < 3) { |
| 2233 | kore_buf_freecxx . . $ kore_buf_free(2648f45d13d14762).(data); |
| 2234 | return; |
| 2235 | } |
| 2236 | |
| 2237 | data->offsetcxx . . $ kore_buf#offset. -= 2; |
| 2238 | string = kore_buf_stringifycxx . . $ kore_buf_stringify(4bc5b263e10e2f7b).(data, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!); |
| 2239 | http_argument_addcxx . . $ http_argument_add(a82b44345cf8406a).(req, name, string, 0, 0); |
| 2240 | kore_buf_freecxx . . $ kore_buf_free(2648f45d13d14762).(data); |
| 2241 | } |
| 2242 | |
| 2243 | static void |
| 2244 | multipart_file_addcxx . . $ multipart_file_add(3722bdda08777045).(struct http_requestcxx . . $ http_request# *req, struct kore_bufcxx . . $ kore_buf# *in, |
| 2245 | const char *name, const char *fname, const char *boundary, const int blen) |
| 2246 | { |
| 2247 | struct http_filecxx . . $ http_file# *f; |
| 2248 | size_t position, len; |
| 2249 | |
| 2250 | position = req->http_body_offsetcxx . . $ http_request#http_body_offset. - in->offsetcxx . . $ kore_buf#offset.; |
| 2251 | if (!multipart_find_datacxx . . $ multipart_find_data(30566873e75e1a09).(in, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, &len, req, boundary, blen)) |
| 2252 | return; |
| 2253 | |
| 2254 | if (len < 3) |
| 2255 | return; |
| 2256 | len -= 2; |
| 2257 | |
| 2258 | f = kore_malloccxx . . $ kore_malloc(bfcfa4d6b7f7ef64).(sizeof(struct http_filecxx . . $ http_file#)); |
| 2259 | f->reqcxx . . $ http_file#req. = req; |
| 2260 | f->offsetcxx . . $ http_file#offset. = 0; |
| 2261 | f->lengthcxx . . $ http_file#length. = len; |
| 2262 | f->positioncxx . . $ http_file#position. = position; |
| 2263 | f->namecxx . . $ http_file#name. = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(name); |
| 2264 | f->filenamecxx . . $ http_file#filename. = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(fname); |
| 2265 | |
| 2266 | TAILQ_INSERT_TAILcxx . . $ `<external>/2546723208511035544/queue.h:402:9`!(&(req->files), f, list); |
| 2267 | } |
| 2268 | |
| 2269 | static void |
| 2270 | http_argument_addcxx . . $ http_argument_add(a82b44345cf8406a).(struct http_requestcxx . . $ http_request# *req, char *name, char *value, int qs, |
| 2271 | int decode) |
| 2272 | { |
| 2273 | struct http_argcxx . . $ http_arg# *q; |
| 2274 | struct kore_route_paramscxx . . $ kore_route_params# *p; |
| 2275 | |
| 2276 | if (decode) { |
| 2277 | if (!http_argument_urldecodecxx . . $ http_argument_urldecode(1ef8e6ec083aabb9).(name)) |
| 2278 | return; |
| 2279 | } |
| 2280 | |
| 2281 | TAILQ_FOREACHcxx . . $ `<external>/2546723208511035544/queue.h:435:9`!(p, &req->rt->params, list) { |
| 2282 | if (qs == 1 && !(p->flagscxx . . $ kore_route_params#flags. & KORE_PARAMS_QUERY_STRINGcxx . . $ `include/kore/kore.h:390:9`!)) |
| 2283 | continue; |
| 2284 | if (qs == 0 && (p->flagscxx . . $ kore_route_params#flags. & KORE_PARAMS_QUERY_STRINGcxx . . $ `include/kore/kore.h:390:9`!)) |
| 2285 | continue; |
| 2286 | |
| 2287 | if (p->methodcxx . . $ kore_route_params#method. != req->methodcxx . . $ http_request#method.) |
| 2288 | continue; |
| 2289 | |
| 2290 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(p->namecxx . . $ kore_route_params#name., name)) |
| 2291 | continue; |
| 2292 | |
| 2293 | if (decode) { |
| 2294 | if (!http_argument_urldecodecxx . . $ http_argument_urldecode(1ef8e6ec083aabb9).(value)) |
| 2295 | return; |
| 2296 | } |
| 2297 | |
| 2298 | if (!kore_validator_checkcxx . . $ kore_validator_check(a50dfed4c9bd2b00).(req, p->validatorcxx . . $ kore_route_params#validator., value)) |
| 2299 | break; |
| 2300 | |
| 2301 | q = kore_malloccxx . . $ kore_malloc(bfcfa4d6b7f7ef64).(sizeof(struct http_argcxx . . $ http_arg#)); |
| 2302 | q->namecxx . . $ http_arg#name. = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(name); |
| 2303 | q->s_valuecxx . . $ http_arg#s_value. = kore_strdupcxx . . $ kore_strdup(a8b8e32347182212).(value); |
| 2304 | TAILQ_INSERT_TAILcxx . . $ `<external>/2546723208511035544/queue.h:402:9`!(&(req->arguments), q, list); |
| 2305 | break; |
| 2306 | } |
| 2307 | } |
| 2308 | |
| 2309 | static int |
| 2310 | http_body_recvcxx . . $ http_body_recv(82c4d452dc2a871a).(struct netbufcxx . . $ netbuf# *nb) |
| 2311 | { |
| 2312 | struct http_requestcxx . . $ http_request# *req = (struct http_requestcxx . . $ http_request# *)nb->extracxx . . $ netbuf#extra.; |
| 2313 | |
| 2314 | return (http_body_updatecxx . . $ http_body_update(eef2fffe5d7d9806).(req, nb->bufcxx . . $ netbuf#buf., nb->s_offcxx . . $ netbuf#s_off.)); |
| 2315 | } |
| 2316 | |
| 2317 | static int |
| 2318 | http_body_updatecxx . . $ http_body_update(eef2fffe5d7d9806).(struct http_requestcxx . . $ http_request# *req, const void *data, size_t len) |
| 2319 | { |
| 2320 | ssize_tcxx . . $ ssize_t# ret; |
| 2321 | u_int64_tcxx . . $ u_int64_t# bytes_left; |
| 2322 | |
| 2323 | SHA256Updatecxx . . $ SHA256Update(39538c1b2db1ed9d).(&req->hashctxcxx . . $ http_request#hashctx., data, len); |
| 2324 | |
| 2325 | if (req->http_body_fdcxx . . $ http_request#http_body_fd. != -1) { |
| 2326 | ret = writecxx . . $ write(41184a59d38b4f65).(req->http_body_fdcxx . . $ http_request#http_body_fd., data, len); |
| 2327 | if (ret == -1 || (size_t)ret != len) { |
| 2328 | req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_DELETEcxx . . $ `include/kore/http.h:242:9`!; |
| 2329 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(req->ownercxx . . $ http_request#owner., |
| 2330 | HTTP_STATUS_INTERNAL_ERRORcxx . . $ HTTP_STATUS_INTERNAL_ERROR.); |
| 2331 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 2332 | } |
| 2333 | } else if (req->http_bodycxx . . $ http_request#http_body. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 2334 | kore_buf_appendcxx . . $ kore_buf_append(4909ebf68ec24f4d).(req->http_bodycxx . . $ http_request#http_body., data, len); |
| 2335 | } else { |
| 2336 | req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_DELETEcxx . . $ `include/kore/http.h:242:9`!; |
| 2337 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(req->ownercxx . . $ http_request#owner., |
| 2338 | HTTP_STATUS_INTERNAL_ERRORcxx . . $ HTTP_STATUS_INTERNAL_ERROR.); |
| 2339 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 2340 | } |
| 2341 | |
| 2342 | req->content_lengthcxx . . $ http_request#content_length. -= len; |
| 2343 | |
| 2344 | if (req->content_lengthcxx . . $ http_request#content_length. == 0) { |
| 2345 | req->ownercxx . . $ http_request#owner.->rnbcxx . . $ connection#rnb.->extracxx . . $ netbuf#extra. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; |
| 2346 | http_request_wakeupcxx . . $ http_request_wakeup(322c51a23f687f95).(req); |
| 2347 | req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_COMPLETEcxx . . $ `include/kore/http.h:241:9`!; |
| 2348 | req->flagscxx . . $ http_request#flags. &= ~HTTP_REQUEST_EXPECT_BODYcxx . . $ `include/kore/http.h:244:9`!; |
| 2349 | req->content_lengthcxx . . $ http_request#content_length. = req->http_body_lengthcxx . . $ http_request#http_body_length.; |
| 2350 | if (!http_body_rewindcxx . . $ http_body_rewind(1f5f2973e69f937).(req)) { |
| 2351 | req->flagscxx . . $ http_request#flags. |= HTTP_REQUEST_DELETEcxx . . $ `include/kore/http.h:242:9`!; |
| 2352 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(req->ownercxx . . $ http_request#owner., |
| 2353 | HTTP_STATUS_INTERNAL_ERRORcxx . . $ HTTP_STATUS_INTERNAL_ERROR.); |
| 2354 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 2355 | } |
| 2356 | SHA256Finalcxx . . $ SHA256Final(f066ac74b575f48f).(req->http_body_digestcxx . . $ http_request#http_body_digest., &req->hashctxcxx . . $ http_request#hashctx.); |
| 2357 | } else { |
| 2358 | bytes_left = req->content_lengthcxx . . $ http_request#content_length.; |
| 2359 | net_recv_resetcxx . . $ net_recv_reset(174c4f3588921332).(req->ownercxx . . $ http_request#owner., |
| 2360 | MINcxx . . $ `<external>/1231830743887005719/param.h:102:9`!(bytes_left, NETBUF_SEND_PAYLOAD_MAXcxx . . $ `include/kore/kore.h:109:9`!), |
| 2361 | http_body_recvcxx . . $ http_body_recv(82c4d452dc2a871a).); |
| 2362 | req->ownercxx . . $ http_request#owner.->rnbcxx . . $ connection#rnb.->extracxx . . $ netbuf#extra. = req; |
| 2363 | } |
| 2364 | |
| 2365 | if (req->rtcxx . . $ http_request#rt.->on_body_chunkcxx . . $ kore_route#on_body_chunk. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && len > 0) { |
| 2366 | kore_runtime_http_body_chunkcxx . . $ kore_runtime_http_body_chunk(37447da8dc885054).(req->rtcxx . . $ http_request#rt.->on_body_chunkcxx . . $ kore_route#on_body_chunk., |
| 2367 | req, data, len); |
| 2368 | } |
| 2369 | |
| 2370 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 2371 | } |
| 2372 | |
| 2373 | static void |
| 2374 | http_error_responsecxx . . $ http_error_response(864ae03f0aacd678).(struct connectioncxx . . $ connection# *c, int status) |
| 2375 | { |
| 2376 | c->flagscxx . . $ connection#flags. |= CONN_CLOSE_EMPTYcxx . . $ `include/kore/kore.h:192:9`!; |
| 2377 | |
| 2378 | switch (c->protocxx . . $ connection#proto.) { |
| 2379 | case CONN_PROTO_HTTPcxx . . $ `include/kore/kore.h:182:9`!: |
| 2380 | http_response_normalcxx . . $ http_response_normal(22e994f97d4c6aa9).(NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, c, status, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, 0); |
| 2381 | break; |
| 2382 | default: |
| 2383 | fatalcxx . . $ fatal(f6bc48f0426f26ee).("http_error_response() bad proto %d", c->protocxx . . $ connection#proto.); |
| 2384 | /* NOTREACHED. */ |
| 2385 | } |
| 2386 | |
| 2387 | if (!net_send_flushcxx . . $ net_send_flush(d3ce87d3c6fa6963).(c)) |
| 2388 | kore_connection_disconnectcxx . . $ kore_connection_disconnect(8475afdb72fd1ebb).(c); |
| 2389 | } |
| 2390 | |
| 2391 | static void |
| 2392 | http_response_normalcxx . . $ http_response_normal(22e994f97d4c6aa9).(struct http_requestcxx . . $ http_request# *req, struct connectioncxx . . $ connection# *c, |
| 2393 | int status, const void *d, size_t len) |
| 2394 | { |
| 2395 | struct kore_bufcxx . . $ kore_buf# buf; |
| 2396 | struct http_cookiecxx . . $ http_cookie# *ck; |
| 2397 | struct http_headercxx . . $ http_header# *hdr; |
| 2398 | char version; |
| 2399 | const char *conn, *text; |
| 2400 | int connection_close, send_body; |
| 2401 | |
| 2402 | send_body = 1; |
| 2403 | text = http_status_textcxx . . $ http_status_text(f7ae7e56280f18ae).(status); |
| 2404 | |
| 2405 | kore_buf_resetcxx . . $ kore_buf_reset(2648f45d13d14762).(header_bufcxx . . $ header_buf.); |
| 2406 | |
| 2407 | if (req != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 2408 | if (req->flagscxx . . $ http_request#flags. & HTTP_VERSION_1_0cxx . . $ `include/kore/http.h:250:9`!) |
| 2409 | version = '0'; |
| 2410 | else |
| 2411 | version = '1'; |
| 2412 | } else { |
| 2413 | version = '1'; |
| 2414 | } |
| 2415 | |
| 2416 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(header_bufcxx . . $ header_buf., "HTTP/1.%c %d %s\r\n", |
| 2417 | version, status, text); |
| 2418 | |
| 2419 | if (status == 100) { |
| 2420 | kore_buf_appendcxx . . $ kore_buf_append(4909ebf68ec24f4d).(header_bufcxx . . $ header_buf., "\r\n", 2); |
| 2421 | net_send_queuecxx . . $ net_send_queue(afc888e1ea7fb691).(c, header_bufcxx . . $ header_buf.->datacxx . . $ kore_buf#data., header_bufcxx . . $ header_buf.->offsetcxx . . $ kore_buf#offset.); |
| 2422 | return; |
| 2423 | } |
| 2424 | |
| 2425 | kore_buf_appendcxx . . $ kore_buf_append(4909ebf68ec24f4d).(header_bufcxx . . $ header_buf., http_versioncxx . . $ http_version., http_version_lencxx . . $ http_version_len.); |
| 2426 | |
| 2427 | if ((c->flagscxx . . $ connection#flags. & CONN_CLOSE_EMPTYcxx . . $ `include/kore/kore.h:192:9`!) || |
| 2428 | (req != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && (req->flagscxx . . $ http_request#flags. & HTTP_VERSION_1_0cxx . . $ `include/kore/http.h:250:9`!))) { |
| 2429 | connection_close = 1; |
| 2430 | } else { |
| 2431 | connection_close = 0; |
| 2432 | } |
| 2433 | |
| 2434 | if (connection_close == 0 && req != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 2435 | if (http_request_headercxx . . $ http_request_header(8b4805cea1886632).(req, "connection", &conn)) { |
| 2436 | if ((*conn == 'c' || *conn == 'C') && |
| 2437 | !strcasecmpcxx . . $ strcasecmp(5ae29d726ae57f88).(conn, "close")) { |
| 2438 | connection_close = 1; |
| 2439 | } |
| 2440 | } |
| 2441 | } |
| 2442 | |
| 2443 | kore_buf_initcxx . . $ kore_buf_init(bd90e0817a56138f).(&buf, 1024); |
| 2444 | |
| 2445 | /* Note that req CAN be NULL. */ |
| 2446 | if (req == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! || req->ownercxx . . $ http_request#owner.->protocxx . . $ connection#proto. != CONN_PROTO_WEBSOCKETcxx . . $ `include/kore/kore.h:183:9`!) { |
| 2447 | if (http_keepalive_timecxx . . $ http_keepalive_time. && connection_close == 0) { |
| 2448 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(header_bufcxx . . $ header_buf., |
| 2449 | "connection: keep-alive\r\n"); |
| 2450 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(header_bufcxx . . $ header_buf., |
| 2451 | "keep-alive: timeout=%d\r\n", http_keepalive_timecxx . . $ http_keepalive_time.); |
| 2452 | } else { |
| 2453 | c->flagscxx . . $ connection#flags. |= CONN_CLOSE_EMPTYcxx . . $ `include/kore/kore.h:192:9`!; |
| 2454 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(header_bufcxx . . $ header_buf., "connection: close\r\n"); |
| 2455 | } |
| 2456 | } |
| 2457 | |
| 2458 | if (c->tlscxx . . $ connection#tls. && http_hsts_enablecxx . . $ http_hsts_enable.) { |
| 2459 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(header_bufcxx . . $ header_buf., "strict-transport-security: "); |
| 2460 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(header_bufcxx . . $ header_buf., |
| 2461 | "max-age=%" PRIu64cxx . . $ `<external>/15933738808807975373/inttypes.h:105:10`! "; includeSubDomains\r\n", |
| 2462 | http_hsts_enablecxx . . $ http_hsts_enable.); |
| 2463 | } |
| 2464 | |
| 2465 | if (http_pretty_errorcxx . . $ http_pretty_error. && d == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && status >= 400) { |
| 2466 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(&buf, pretty_error_fmtcxx . . $ pretty_error_fmt., |
| 2467 | status, text, status, text); |
| 2468 | |
| 2469 | d = buf.datacxx . . $ kore_buf#data.; |
| 2470 | len = buf.offsetcxx . . $ kore_buf#offset.; |
| 2471 | } |
| 2472 | |
| 2473 | if (req != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 2474 | TAILQ_FOREACHcxx . . $ `<external>/2546723208511035544/queue.h:435:9`!(ck, &(req->resp_cookies), list) |
| 2475 | http_write_response_cookiecxx . . $ http_write_response_cookie(c4b6faa0b9983ba1).(ck); |
| 2476 | |
| 2477 | TAILQ_FOREACHcxx . . $ `<external>/2546723208511035544/queue.h:435:9`!(hdr, &(req->resp_headers), list) { |
| 2478 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(header_bufcxx . . $ header_buf., "%s: %s\r\n", |
| 2479 | hdr->headercxx . . $ http_header#header., hdr->valuecxx . . $ http_header#value.); |
| 2480 | } |
| 2481 | |
| 2482 | if (status != 204 && status >= 200 && |
| 2483 | !(req->flagscxx . . $ http_request#flags. & HTTP_REQUEST_NO_CONTENT_LENGTHcxx . . $ `include/kore/http.h:246:9`!)) { |
| 2484 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(header_bufcxx . . $ header_buf., |
| 2485 | "content-length: %zu\r\n", len); |
| 2486 | } |
| 2487 | } else { |
| 2488 | if (status != 204 && status >= 200) { |
| 2489 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(header_bufcxx . . $ header_buf., |
| 2490 | "content-length: %zu\r\n", len); |
| 2491 | } |
| 2492 | } |
| 2493 | |
| 2494 | kore_buf_appendcxx . . $ kore_buf_append(4909ebf68ec24f4d).(header_bufcxx . . $ header_buf., "\r\n", 2); |
| 2495 | net_send_queuecxx . . $ net_send_queue(afc888e1ea7fb691).(c, header_bufcxx . . $ header_buf.->datacxx . . $ kore_buf#data., header_bufcxx . . $ header_buf.->offsetcxx . . $ kore_buf#offset.); |
| 2496 | |
| 2497 | if (req != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && req->methodcxx . . $ http_request#method. == HTTP_METHOD_HEADcxx . . $ `include/kore/http.h:233:9`!) |
| 2498 | send_body = 0; |
| 2499 | |
| 2500 | if (d != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`! && send_body) |
| 2501 | net_send_queuecxx . . $ net_send_queue(afc888e1ea7fb691).(c, d, len); |
| 2502 | |
| 2503 | if (!(c->flagscxx . . $ connection#flags. & CONN_CLOSE_EMPTYcxx . . $ `include/kore/kore.h:192:9`!) && !(c->flagscxx . . $ connection#flags. & CONN_IS_BUSYcxx . . $ `include/kore/kore.h:194:9`!)) |
| 2504 | http_start_recvcxx . . $ http_start_recv(8475afdb72fd1ebb).(c); |
| 2505 | |
| 2506 | if (req != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2507 | req->content_lengthcxx . . $ http_request#content_length. = len; |
| 2508 | |
| 2509 | kore_buf_cleanupcxx . . $ kore_buf_cleanup(2648f45d13d14762).(&buf); |
| 2510 | } |
| 2511 | |
| 2512 | static void |
| 2513 | http_write_response_cookiecxx . . $ http_write_response_cookie(c4b6faa0b9983ba1).(struct http_cookiecxx . . $ http_cookie# *ck) |
| 2514 | { |
| 2515 | struct tmcxx . . $ tm# tm; |
| 2516 | char expires[HTTP_DATE_MAXSIZEcxx . . $ `include/kore/http.h:47:9`!]; |
| 2517 | |
| 2518 | kore_buf_resetcxx . . $ kore_buf_reset(2648f45d13d14762).(ckhdr_bufcxx . . $ ckhdr_buf.); |
| 2519 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(ckhdr_bufcxx . . $ ckhdr_buf., "%s=%s", ck->namecxx . . $ http_cookie#name., ck->valuecxx . . $ http_cookie#value.); |
| 2520 | |
| 2521 | if (ck->pathcxx . . $ http_cookie#path. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2522 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(ckhdr_bufcxx . . $ ckhdr_buf., "; Path=%s", ck->pathcxx . . $ http_cookie#path.); |
| 2523 | if (ck->domaincxx . . $ http_cookie#domain. != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) |
| 2524 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(ckhdr_bufcxx . . $ ckhdr_buf., "; Domain=%s", ck->domaincxx . . $ http_cookie#domain.); |
| 2525 | |
| 2526 | if (ck->expirescxx . . $ http_cookie#expires. > 0) { |
| 2527 | if (gmtime_rcxx . . $ gmtime_r(92e3d173686db852).(&ck->expirescxx . . $ http_cookie#expires., &tm) == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!) { |
| 2528 | kore_logcxx . . $ kore_log(afcfcee7634adf7d).(LOG_ERRcxx . . $ `<external>/6168640806541382331/syslog.h:54:9`!, "gmtime_r(): %s", errno_scxx . . $ `include/kore/kore.h:100:9`!); |
| 2529 | return; |
| 2530 | } |
| 2531 | |
| 2532 | if (strftimecxx . . $ strftime(98e75925167c4f1b).(expires, sizeof(expires), |
| 2533 | "%a, %d %b %y %H:%M:%S GMT", &tm) == 0) { |
| 2534 | kore_logcxx . . $ kore_log(afcfcee7634adf7d).(LOG_ERRcxx . . $ `<external>/6168640806541382331/syslog.h:54:9`!, "strftime(): %s", errno_scxx . . $ `include/kore/kore.h:100:9`!); |
| 2535 | return; |
| 2536 | } |
| 2537 | |
| 2538 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(ckhdr_bufcxx . . $ ckhdr_buf., "; Expires=%s", expires); |
| 2539 | } |
| 2540 | |
| 2541 | if (ck->maxagecxx . . $ http_cookie#maxage. > 0) |
| 2542 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(ckhdr_bufcxx . . $ ckhdr_buf., "; Max-Age=%u", ck->maxagecxx . . $ http_cookie#maxage.); |
| 2543 | |
| 2544 | if (ck->flagscxx . . $ http_cookie#flags. & HTTP_COOKIE_HTTPONLYcxx . . $ `include/kore/http.h:91:9`!) |
| 2545 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(ckhdr_bufcxx . . $ ckhdr_buf., "; HttpOnly"); |
| 2546 | if (ck->flagscxx . . $ http_cookie#flags. & HTTP_COOKIE_SECUREcxx . . $ `include/kore/http.h:92:9`!) |
| 2547 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(ckhdr_bufcxx . . $ ckhdr_buf., "; Secure"); |
| 2548 | |
| 2549 | kore_buf_appendfcxx . . $ kore_buf_appendf(e492ffcef53d871e).(header_bufcxx . . $ header_buf., "set-cookie: %s\r\n", |
| 2550 | kore_buf_stringifycxx . . $ kore_buf_stringify(4bc5b263e10e2f7b).(ckhdr_bufcxx . . $ ckhdr_buf., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)); |
| 2551 | } |
| 2552 | |
| 2553 | static int |
| 2554 | http_data_convertcxx . . $ http_data_convert(68f79bd69bedc53).(void *data, void **out, void *nout, int type) |
| 2555 | { |
| 2556 | switch (type) { |
| 2557 | case HTTP_ARG_TYPE_RAWcxx . . $ `include/kore/http.h:57:9`!: |
| 2558 | case HTTP_ARG_TYPE_STRINGcxx . . $ `include/kore/http.h:63:9`!: |
| 2559 | *out = data; |
| 2560 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 2561 | case HTTP_ARG_TYPE_BYTEcxx . . $ `include/kore/http.h:58:9`!: |
| 2562 | COPY_ARG_TYPEcxx . . $ `include/kore/http.h:113:9`!(*(u_int8_t *)data, u_int8_t); |
| 2563 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 2564 | case HTTP_ARG_TYPE_INT16cxx . . $ `include/kore/http.h:59:9`!: |
| 2565 | COPY_AS_INTTYPEcxx . . $ `include/kore/http.h:155:9`!(SHRT_MINcxx . . $ `<external>/67164224788392828/limits.h:104:9`!, SHRT_MAXcxx . . $ `<external>/67164224788392828/limits.h:106:9`!, int16_t); |
| 2566 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 2567 | case HTTP_ARG_TYPE_UINT16cxx . . $ `include/kore/http.h:60:9`!: |
| 2568 | COPY_AS_INTTYPEcxx . . $ `include/kore/http.h:155:9`!(0, USHRT_MAXcxx . . $ `<external>/67164224788392828/limits.h:113:10`!, u_int16_t); |
| 2569 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 2570 | case HTTP_ARG_TYPE_INT32cxx . . $ `include/kore/http.h:61:9`!: |
| 2571 | COPY_AS_INTTYPEcxx . . $ `include/kore/http.h:155:9`!(INT_MINcxx . . $ `<external>/67164224788392828/limits.h:118:9`!, INT_MAXcxx . . $ `<external>/67164224788392828/limits.h:120:9`!, int32_t); |
| 2572 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 2573 | case HTTP_ARG_TYPE_UINT32cxx . . $ `include/kore/http.h:62:9`!: |
| 2574 | COPY_AS_INTTYPEcxx . . $ `include/kore/http.h:155:9`!(0, UINT_MAXcxx . . $ `<external>/67164224788392828/limits.h:124:9`!, u_int32_t); |
| 2575 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 2576 | case HTTP_ARG_TYPE_INT64cxx . . $ `include/kore/http.h:64:9`!: |
| 2577 | COPY_AS_INTTYPE_64cxx . . $ `include/kore/http.h:148:9`!(int64_t, 1); |
| 2578 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 2579 | case HTTP_ARG_TYPE_UINT64cxx . . $ `include/kore/http.h:65:9`!: |
| 2580 | COPY_AS_INTTYPE_64cxx . . $ `include/kore/http.h:148:9`!(u_int64_t, 0); |
| 2581 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 2582 | case HTTP_ARG_TYPE_FLOATcxx . . $ `include/kore/http.h:66:9`!: |
| 2583 | COPY_ARG_DOUBLEcxx . . $ `include/kore/http.h:128:9`!(-FLT_MAXcxx . . $ `<external>/18143172452841944454/float.h:104:9`!, FLT_MAXcxx . . $ `<external>/18143172452841944454/float.h:104:9`!, float); |
| 2584 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 2585 | case HTTP_ARG_TYPE_DOUBLEcxx . . $ `include/kore/http.h:67:9`!: |
| 2586 | COPY_ARG_DOUBLEcxx . . $ `include/kore/http.h:128:9`!(-DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!, DBL_MAXcxx . . $ `<external>/18143172452841944454/float.h:105:9`!, double); |
| 2587 | return (KORE_RESULT_OKcxx . . $ `include/kore/kore.h:88:9`!); |
| 2588 | default: |
| 2589 | break; |
| 2590 | } |
| 2591 | |
| 2592 | return (KORE_RESULT_ERRORcxx . . $ `include/kore/kore.h:87:9`!); |
| 2593 | } |