mirror of
https://github.com/cesanta/mongoose.git
synced 2025-06-08 01:42:52 +08:00
Improve error reporting of mg_connect_http
PUBLISHED_FROM=8149fc5ab3c6f7d6ec360473f0e6847040ca820b
This commit is contained in:
parent
b667bd709d
commit
a3e2a41834
@ -5853,8 +5853,10 @@ void mg_http_reverse_proxy(struct mg_connection *nc,
|
|||||||
char *addr = NULL;
|
char *addr = NULL;
|
||||||
const char *path = NULL;
|
const char *path = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
const char *error;
|
||||||
struct mg_connect_opts opts;
|
struct mg_connect_opts opts;
|
||||||
memset(&opts, 0, sizeof(opts));
|
memset(&opts, 0, sizeof(opts));
|
||||||
|
opts.error_string = &error;
|
||||||
|
|
||||||
mg_asprintf(&purl, sizeof(burl), "%.*s%.*s", (int) upstream.len, upstream.p,
|
mg_asprintf(&purl, sizeof(burl), "%.*s%.*s", (int) upstream.len, upstream.p,
|
||||||
(int) (hm->uri.len - mount.len), hm->uri.p + mount.len);
|
(int) (hm->uri.len - mount.len), hm->uri.p + mount.len);
|
||||||
@ -5865,6 +5867,7 @@ void mg_http_reverse_proxy(struct mg_connection *nc,
|
|||||||
(int) mount.len, mount.p));
|
(int) mount.len, mount.p));
|
||||||
|
|
||||||
if (be == NULL) {
|
if (be == NULL) {
|
||||||
|
LOG(LL_ERROR, ("Error connecting to %s: %s", purl, error));
|
||||||
mg_http_send_error(nc, 502, NULL);
|
mg_http_send_error(nc, 502, NULL);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
@ -6394,6 +6397,7 @@ struct mg_connection *mg_connect_http_base(
|
|||||||
|
|
||||||
if (mg_http_common_url_parse(url, schema, schema_ssl, &use_ssl, addr, &port_i,
|
if (mg_http_common_url_parse(url, schema, schema_ssl, &use_ssl, addr, &port_i,
|
||||||
path) < 0) {
|
path) < 0) {
|
||||||
|
MG_SET_PTRPTR(opts.error_string, "cannot parse url");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user