mirror of
https://github.com/curl/curl.git
synced 2026-08-03 01:30:29 +03:00
URL-API
See header file and man pages for API. All documented API details work and are tested in the 1560 test case. Closes #2842
This commit is contained in:
parent
17ca0ccff4
commit
fb30ac5a2d
24 changed files with 2814 additions and 365 deletions
44
lib/url.c
44
lib/url.c
|
|
@ -1944,30 +1944,37 @@ static struct connectdata *allocate_conn(struct Curl_easy *data)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/* returns the handdler if the given scheme is built-in */
|
||||
const struct Curl_handler *Curl_builtin_scheme(const char *scheme)
|
||||
{
|
||||
const struct Curl_handler * const *pp;
|
||||
const struct Curl_handler *p;
|
||||
/* Scan protocol handler table and match against 'scheme'. The handler may
|
||||
be changed later when the protocol specific setup function is called. */
|
||||
for(pp = protocols; (p = *pp) != NULL; pp++)
|
||||
if(strcasecompare(p->scheme, scheme))
|
||||
/* Protocol found in table. Check if allowed */
|
||||
return p;
|
||||
return NULL; /* not found */
|
||||
}
|
||||
|
||||
|
||||
static CURLcode findprotocol(struct Curl_easy *data,
|
||||
struct connectdata *conn,
|
||||
const char *protostr)
|
||||
{
|
||||
const struct Curl_handler * const *pp;
|
||||
const struct Curl_handler *p;
|
||||
const struct Curl_handler *p = Curl_builtin_scheme(protostr);
|
||||
|
||||
/* Scan protocol handler table and match against 'protostr' to set a few
|
||||
variables based on the URL. Now that the handler may be changed later
|
||||
when the protocol specific setup function is called. */
|
||||
for(pp = protocols; (p = *pp) != NULL; pp++) {
|
||||
if(strcasecompare(p->scheme, protostr)) {
|
||||
/* Protocol found in table. Check if allowed */
|
||||
if(!(data->set.allowed_protocols & p->protocol))
|
||||
/* nope, get out */
|
||||
break;
|
||||
|
||||
/* it is allowed for "normal" request, now do an extra check if this is
|
||||
the result of a redirect */
|
||||
if(data->state.this_is_a_follow &&
|
||||
!(data->set.redir_protocols & p->protocol))
|
||||
/* nope, get out */
|
||||
break;
|
||||
if(p && /* Protocol found in table. Check if allowed */
|
||||
(data->set.allowed_protocols & p->protocol)) {
|
||||
|
||||
/* it is allowed for "normal" request, now do an extra check if this is
|
||||
the result of a redirect */
|
||||
if(data->state.this_is_a_follow &&
|
||||
!(data->set.redir_protocols & p->protocol))
|
||||
/* nope, get out */
|
||||
;
|
||||
else {
|
||||
/* Perform setup complement if some. */
|
||||
conn->handler = conn->given = p;
|
||||
|
||||
|
|
@ -1976,7 +1983,6 @@ static CURLcode findprotocol(struct Curl_easy *data,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* The protocol was not found in the table, but we don't have to assign it
|
||||
to anything since it is already assigned to a dummy-struct in the
|
||||
create_conn() function when the connectdata struct is allocated. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue