mirror of
https://github.com/libretro/RetroArch
synced 2025-04-17 02:43:03 +00:00
Minor cleanup
This commit is contained in:
parent
c7f839a7fd
commit
4092fd7e83
@ -327,10 +327,7 @@ bool net_http_connection_done(struct http_connection_t *conn)
|
|||||||
{
|
{
|
||||||
int has_port = 0;
|
int has_port = 0;
|
||||||
|
|
||||||
if (!conn)
|
if (!conn || !conn->domain || !*conn->domain)
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!conn->domain || !*conn->domain)
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (*conn->scan == ':')
|
if (*conn->scan == ':')
|
||||||
@ -357,7 +354,7 @@ bool net_http_connection_done(struct http_connection_t *conn)
|
|||||||
{
|
{
|
||||||
/* domain followed by location - split off the location */
|
/* domain followed by location - split off the location */
|
||||||
/* site.com/path.html or site.com:80/path.html */
|
/* site.com/path.html or site.com:80/path.html */
|
||||||
*conn->scan = '\0';
|
*conn->scan = '\0';
|
||||||
conn->location = conn->scan + 1;
|
conn->location = conn->scan + 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -375,30 +372,28 @@ bool net_http_connection_done(struct http_connection_t *conn)
|
|||||||
if (!has_port)
|
if (!has_port)
|
||||||
{
|
{
|
||||||
/* if there wasn't a port, we have to expand the urlcopy so we can separate the two parts */
|
/* if there wasn't a port, we have to expand the urlcopy so we can separate the two parts */
|
||||||
size_t domain_len = strlen(conn->domain);
|
size_t domain_len = strlen(conn->domain);
|
||||||
size_t location_len = strlen(conn->scan);
|
size_t location_len = strlen(conn->scan);
|
||||||
char* urlcopy = (char*)malloc(domain_len + location_len + 2);
|
char* urlcopy = (char*)malloc(domain_len + location_len + 2);
|
||||||
memcpy(urlcopy, conn->domain, domain_len);
|
memcpy(urlcopy, conn->domain, domain_len);
|
||||||
urlcopy[domain_len] = '\0';
|
urlcopy[domain_len] = '\0';
|
||||||
memcpy(urlcopy + domain_len + 1, conn->scan, location_len + 1);
|
memcpy(urlcopy + domain_len + 1, conn->scan, location_len + 1);
|
||||||
|
|
||||||
free(conn->urlcopy);
|
free(conn->urlcopy);
|
||||||
conn->domain = conn->urlcopy = urlcopy;
|
conn->domain = conn->urlcopy = urlcopy;
|
||||||
conn->location = conn->scan = urlcopy + domain_len + 1;
|
conn->location = conn->scan = urlcopy + domain_len + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* there was a port, so overwriting the : will terminate the domain and we can just point at the ? */
|
/* there was a port, so overwriting the : will terminate the domain and we can just point at the ? */
|
||||||
conn->location = conn->scan;
|
conn->location = conn->scan;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
/* invalid character after domain/port */
|
||||||
/* invalid character after domain/port */
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void net_http_connection_free(struct http_connection_t *conn)
|
void net_http_connection_free(struct http_connection_t *conn)
|
||||||
@ -430,7 +425,8 @@ void net_http_connection_free(struct http_connection_t *conn)
|
|||||||
free(conn);
|
free(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void net_http_connection_set_user_agent(struct http_connection_t* conn, const char* user_agent)
|
void net_http_connection_set_user_agent(
|
||||||
|
struct http_connection_t* conn, const char* user_agent)
|
||||||
{
|
{
|
||||||
if (conn->useragentcopy)
|
if (conn->useragentcopy)
|
||||||
free(conn->useragentcopy);
|
free(conn->useragentcopy);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user