11 #define SOCKET_HTTP_MAX_HEADER_LENGTH 0x2000
12 #define SOCKET_HTTP_MAX_REDIRECTS 5
54 if (drn && (drn < dnn)) {
76 eprintf(
"Too many redirects\n");
79 p += strlen(
"Location:");
80 char *end_url = strchr(
p,
'\n');
82 int url_len = end_url -
p;
113 }
while (olen <
len);
136 static char *http_get_w32(
const char *
url,
int *
code,
int *rlen) {
137 HINTERNET hInternet = InternetOpenA(
"rizin " RZ_VERSION, INTERNET_OPEN_TYPE_DIRECT,
NULL,
NULL, 0);
142 HINTERNET hOpenUrl = InternetOpenUrlA(hInternet,
url,
NULL, 0, 0, 0);
145 InternetCloseHandle(hInternet);
150 size_t read_sz = 0x100000;
155 if (!res && GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
164 }
while (!(res = InternetReadFile(hOpenUrl, ret +
w, read_sz, &
r)) ||
r);
185 InternetCloseHandle(hInternet);
186 InternetCloseHandle(hOpenUrl);
222 return http_get_w32(
url,
code, rlen);
228 eprintf(
"Tried to get '%s', but SSL support is disabled, set RZ_CURL=1 to use curl\n",
url);
232 char *response, *host, *
path, *port =
"80";
237 host = strstr(uri,
"://");
240 eprintf(
"rz_socket_http_get: Invalid URI");
244 port = strchr(host,
':');
247 port = ssl ?
"443" :
"80";
264 eprintf(
"rz_socket_http_get: Cannot create socket\n");
270 "GET /%s HTTP/1.1\r\n"
278 eprintf(
"Cannot connect to %s:%s\n", host, port);
299 char *host = strstr(uri,
"://");
306 char *port = strchr(host,
':');
308 port = (ssl) ?
"443" :
"80";
312 char *
path = strchr(host,
'/');
320 printf(
"Cannot create socket\n");
325 eprintf(
"Cannot connect to %s:%s\n", host, port);
331 "POST /%s HTTP/1.0\r\n"
335 "Content-Length: %i\r\n"
336 "Content-Type: application/x-www-form-urlencoded\r\n"
338 path, host, (
int)strlen(data));
_Use_decl_annotations_ int __cdecl printf(const char *const _Format,...)
static static fork const void static count static fd const char const char static newpath const char static path const char path
RZ_API void Ht_() free(HtName_(Ht) *ht)
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
void * realloc(void *ptr, size_t size)
void * malloc(size_t size)
return strdup("=SP r13\n" "=LR r14\n" "=PC r15\n" "=A0 r0\n" "=A1 r1\n" "=A2 r2\n" "=A3 r3\n" "=ZF zf\n" "=SF nf\n" "=OF vf\n" "=CF cf\n" "=SN or0\n" "gpr lr .32 56 0\n" "gpr pc .32 60 0\n" "gpr cpsr .32 64 0 ____tfiae_________________qvczn\n" "gpr or0 .32 68 0\n" "gpr tf .1 64.5 0 thumb\n" "gpr ef .1 64.9 0 endian\n" "gpr jf .1 64.24 0 java\n" "gpr qf .1 64.27 0 sticky_overflow\n" "gpr vf .1 64.28 0 overflow\n" "gpr cf .1 64.29 0 carry\n" "gpr zf .1 64.30 0 zero\n" "gpr nf .1 64.31 0 negative\n" "gpr itc .4 64.10 0 if_then_count\n" "gpr gef .4 64.16 0 great_or_equal\n" "gpr r0 .32 0 0\n" "gpr r1 .32 4 0\n" "gpr r2 .32 8 0\n" "gpr r3 .32 12 0\n" "gpr r4 .32 16 0\n" "gpr r5 .32 20 0\n" "gpr r6 .32 24 0\n" "gpr r7 .32 28 0\n" "gpr r8 .32 32 0\n" "gpr r9 .32 36 0\n" "gpr r10 .32 40 0\n" "gpr r11 .32 44 0\n" "gpr r12 .32 48 0\n" "gpr r13 .32 52 0\n" "gpr r14 .32 56 0\n" "gpr r15 .32 60 0\n" "gpr r16 .32 64 0\n" "gpr r17 .32 68 0\n")
#define rz_return_val_if_fail(expr, val)
RZ_API bool rz_buf_append_bytes(RZ_NONNULL RzBuffer *b, RZ_NONNULL const ut8 *buf, ut64 len)
Append an array of bytes to the buffer.
RZ_API st64 rz_buf_read_at(RZ_NONNULL RzBuffer *b, ut64 addr, RZ_NONNULL RZ_OUT ut8 *buf, ut64 len)
Read len bytes of the buffer at the specified address.
RZ_API void rz_buf_free(RzBuffer *b)
Free all internal data hold by the buffer and the buffer.
RZ_API RZ_OWN RzBuffer * rz_buf_new_with_bytes(RZ_NULLABLE RZ_BORROW const ut8 *bytes, ut64 len)
Creates a new buffer with a bytes array.
RZ_API int rz_socket_close(RzSocket *s)
RZ_API int rz_socket_read_block(RzSocket *s, unsigned char *buf, int len)
RZ_API int rz_socket_ready(RzSocket *s, int secs, int usecs)
#define rz_socket_connect_tcp(a, b, c, d)
RZ_API bool rz_socket_block_time(RzSocket *s, bool block, int sec, int usec)
RZ_API void rz_socket_printf(RzSocket *s, const char *fmt,...) RZ_PRINTF_CHECK(2
RZ_API RzSocket * rz_socket_new(bool is_ssl)
RZ_API int rz_socket_free(RzSocket *s)
RZ_API int rz_socket_write(RzSocket *s, void *buf, int len)
RZ_API char * rz_str_newf(const char *fmt,...) RZ_PRINTF_CHECK(1
RZ_API char * rz_str_ndup(RZ_NULLABLE const char *ptr, int len)
Create new copy of string ptr limited to size len.
#define RZ_STR_ISEMPTY(x)
RZ_API void rz_str_trim(RZ_NONNULL RZ_INOUT char *str)
Removes whitespace characters (space, tab, newline etc.) from the beginning and end of a string.
RZ_API bool rz_str_startswith(RZ_NONNULL const char *str, RZ_NONNULL const char *needle)
Checks if a string starts with a specifc sequence of characters (case sensitive)
RZ_API const char * rz_str_casestr(const char *a, const char *b)
RZ_API char * rz_str_escape_sh(const char *buf)
RZ_API char * rz_sys_getenv(const char *key)
Get the value of an environment variable named key or NULL if none exists.
RZ_API int RZ_API char * rz_sys_cmd_str(const char *cmd, const char *input, int *len)
#define SOCKET_HTTP_MAX_REDIRECTS
static char * socket_http_answer(RzSocket *s, int *code, int *rlen, ut32 redirections)
static char * socket_http_get_recursive(const char *url, int *code, int *rlen, ut32 redirections)
static size_t socket_slurp(RzSocket *s, RzBuffer *buf)
#define SOCKET_HTTP_MAX_HEADER_LENGTH
RZ_API char * rz_socket_http_get(const char *url, int *code, int *rlen)
RZ_API char * rz_socket_http_post(const char *url, const char *data, int *code, int *rlen)