Lines Matching +full:port +full:- +full:base

2  * http_client - HTTP client
40 c->cb(c->cb_ctx, c, HTTP_CLIENT_TIMEOUT); in http_client_timeout()
55 if (httpread_hdr_type_get(c->hread) == HTTPREAD_HDR_TYPE_REPLY) in http_client_got_response()
57 int reply_code = httpread_reply_code_get(c->hread); in http_client_got_response()
61 inet_ntoa(c->dst.sin_addr), in http_client_got_response()
62 ntohs(c->dst.sin_port)); in http_client_got_response()
63 c->cb(c->cb_ctx, c, HTTP_CLIENT_OK); in http_client_got_response()
67 inet_ntoa(c->dst.sin_addr), in http_client_got_response()
68 ntohs(c->dst.sin_port)); in http_client_got_response()
69 c->cb(c->cb_ctx, c, HTTP_CLIENT_INVALID_REPLY); in http_client_got_response()
72 c->cb(c->cb_ctx, c, HTTP_CLIENT_INVALID_REPLY); in http_client_got_response()
75 c->cb(c->cb_ctx, c, HTTP_CLIENT_TIMEOUT); in http_client_got_response()
78 c->cb(c->cb_ctx, c, HTTP_CLIENT_FAILED); in http_client_got_response()
90 send_len = wpabuf_len(c->req) - c->req_pos; in http_client_tx_ready()
93 inet_ntoa(c->dst.sin_addr), ntohs(c->dst.sin_port), in http_client_tx_ready()
94 (unsigned long) wpabuf_len(c->req), in http_client_tx_ready()
97 res = send(c->sd, wpabuf_head_u8(c->req) + c->req_pos, send_len, 0); in http_client_tx_ready()
101 eloop_unregister_sock(c->sd, EVENT_TYPE_WRITE); in http_client_tx_ready()
102 c->cb(c->cb_ctx, c, HTTP_CLIENT_FAILED); in http_client_tx_ready()
109 res, (unsigned long) wpabuf_len(c->req), in http_client_tx_ready()
110 (unsigned long) send_len - res); in http_client_tx_ready()
111 c->req_pos += res; in http_client_tx_ready()
116 inet_ntoa(c->dst.sin_addr), ntohs(c->dst.sin_port)); in http_client_tx_ready()
117 eloop_unregister_sock(c->sd, EVENT_TYPE_WRITE); in http_client_tx_ready()
118 wpabuf_free(c->req); in http_client_tx_ready()
119 c->req = NULL; in http_client_tx_ready()
121 c->hread = httpread_create(c->sd, http_client_got_response, c, in http_client_tx_ready()
122 c->max_response, HTTP_CLIENT_TIMEOUT_SEC); in http_client_tx_ready()
123 if (c->hread == NULL) { in http_client_tx_ready()
124 c->cb(c->cb_ctx, c, HTTP_CLIENT_FAILED); in http_client_tx_ready()
142 c->sd = -1; in http_client_addr()
143 c->dst = *dst; in http_client_addr()
144 c->max_response = max_response; in http_client_addr()
145 c->cb = cb; in http_client_addr()
146 c->cb_ctx = cb_ctx; in http_client_addr()
148 c->sd = socket(AF_INET, SOCK_STREAM, 0); in http_client_addr()
149 if (c->sd < 0) in http_client_addr()
152 if (fcntl(c->sd, F_SETFL, O_NONBLOCK) != 0) { in http_client_addr()
158 if (connect(c->sd, (struct sockaddr *) dst, sizeof(*dst))) { in http_client_addr()
171 if (eloop_register_sock(c->sd, EVENT_TYPE_WRITE, http_client_tx_ready, in http_client_addr()
177 c->req = req; in http_client_addr()
190 char *u, *addr, *port, *path; in http_client_url_parse() local
197 dst->sin_family = AF_INET; in http_client_url_parse()
200 port = os_strchr(addr, ':'); in http_client_url_parse()
205 if (port > path) in http_client_url_parse()
206 port = NULL; in http_client_url_parse()
208 if (port) in http_client_url_parse()
209 *port++ = '\0'; in http_client_url_parse()
211 if (inet_aton(addr, &dst->sin_addr) == 0) { in http_client_url_parse()
214 "(addr='%s' port='%s')", in http_client_url_parse()
215 url, addr, port); in http_client_url_parse()
220 if (port) in http_client_url_parse()
221 dst->sin_port = htons(atoi(port)); in http_client_url_parse()
223 dst->sin_port = htons(80); in http_client_url_parse()
263 "Cache-Control: no-cache\r\n" in http_client_url()
264 "Pragma: no-cache\r\n" in http_client_url()
266 "User-Agent: wpa_supplicant\r\n" in http_client_url()
288 httpread_destroy(c->hread); in http_client_free()
289 wpabuf_free(c->req); in http_client_free()
290 if (c->sd >= 0) { in http_client_free()
291 eloop_unregister_sock(c->sd, EVENT_TYPE_WRITE); in http_client_free()
292 close(c->sd); in http_client_free()
301 if (c->hread == NULL) in http_client_get_body()
303 wpabuf_set(&c->body, httpread_data_get(c->hread), in http_client_get_body()
304 httpread_length_get(c->hread)); in http_client_get_body()
305 return &c->body; in http_client_get_body()
311 if (c->hread == NULL) in http_client_get_hdr_line()
313 return httpread_hdr_line_get(c->hread, tag); in http_client_get_hdr_line()
317 char * http_link_update(char *url, const char *base) in http_link_update() argument
332 if (os_strncmp(base, "http://", 7) != 0) in http_link_update()
333 return url; /* unable to handle base URL */ in http_link_update()
335 len = os_strlen(url) + 1 + os_strlen(base) + 1; in http_link_update()
341 pos = os_strchr(base + 7, '/'); in http_link_update()
343 os_snprintf(n, len, "%s%s", base, url); in http_link_update()
345 os_memcpy(n, base, pos - base); in http_link_update()
346 os_memcpy(n + (pos - base), url, os_strlen(url) + 1); in http_link_update()
349 pos = os_strrchr(base + 7, '/'); in http_link_update()
351 os_snprintf(n, len, "%s/%s", base, url); in http_link_update()
353 os_memcpy(n, base, pos - base + 1); in http_link_update()
354 os_memcpy(n + (pos - base) + 1, url, os_strlen(url) + in http_link_update()