mirror of
https://github.com/lammertb/libhttp.git
synced 2025-12-22 04:02:04 +03:00
Support absolute uri (#197) - (Step 2/?)
This commit is contained in:
@@ -9838,13 +9838,12 @@ struct mg_connection *mg_connect_client(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int is_valid_uri(const char *uri, const struct mg_context *ctx)
|
static int is_valid_uri(const char *uri, const struct mg_connection *conn)
|
||||||
{
|
{
|
||||||
const char *domain;
|
const char *domain;
|
||||||
size_t domain_len;
|
size_t domain_len;
|
||||||
unsigned long port;
|
unsigned long port;
|
||||||
char *pend;
|
char *pend;
|
||||||
int i;
|
|
||||||
|
|
||||||
/* According to the HTTP standard
|
/* According to the HTTP standard
|
||||||
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2
|
* http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2
|
||||||
@@ -9858,7 +9857,7 @@ static int is_valid_uri(const char *uri, const struct mg_context *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* DNS is case insensitive, so use case insensitive string compare here */
|
/* DNS is case insensitive, so use case insensitive string compare here */
|
||||||
domain = ctx->config[AUTHENTICATION_DOMAIN];
|
domain = conn->ctx->config[AUTHENTICATION_DOMAIN];
|
||||||
if (!domain) {
|
if (!domain) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -9940,13 +9939,13 @@ static int is_valid_uri(const char *uri, const struct mg_context *ctx)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < (int)ctx->num_listening_sockets; i++) {
|
#if defined(USE_IPV6)
|
||||||
if (ctx->listening_ports[i] == port) {
|
if (conn->client.lsa.sa.sa_family == AF_INET6) {
|
||||||
return 1;
|
return (conn->client.lsa.sin6.sin6_port == port);
|
||||||
}
|
}
|
||||||
}
|
#endif
|
||||||
|
|
||||||
return 0;
|
return (conn->client.lsa.sin.sin_port == port);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -10317,7 +10316,7 @@ static void process_new_connection(struct mg_connection *conn)
|
|||||||
/*assert(ebuf[0] != '\0');*/
|
/*assert(ebuf[0] != '\0');*/
|
||||||
send_http_error(conn, reqerr, "%s", ebuf);
|
send_http_error(conn, reqerr, "%s", ebuf);
|
||||||
}
|
}
|
||||||
} else if (!is_valid_uri(conn->request_info.uri, conn->ctx)) {
|
} else if (!is_valid_uri(conn->request_info.uri, conn)) {
|
||||||
mg_snprintf(conn,
|
mg_snprintf(conn,
|
||||||
NULL, /* No truncation check for ebuf */
|
NULL, /* No truncation check for ebuf */
|
||||||
ebuf,
|
ebuf,
|
||||||
|
|||||||
Reference in New Issue
Block a user