Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
timidity
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
redox-os
timidity
Commits
14f7ff53
Commit
14f7ff53
authored
13 years ago
by
SATO Kentaro
Browse files
Options
Downloads
Patches
Plain Diff
Fix HTTPproxy not working on http URL.
parent
e8823256
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libarc/url_http.c
+42
-52
42 additions, 52 deletions
libarc/url_http.c
with
42 additions
and
52 deletions
libarc/url_http.c
+
42
−
52
View file @
14f7ff53
...
...
@@ -92,11 +92,37 @@ static void timeout(int sig)
timeout_flag
=
1
;
}
static
char
*
get_http_url_host_port
(
const
char
*
url
,
char
*
buffer
,
int
buffer_size
)
{
const
char
*
host
=
url
;
const
char
*
host_end
;
int
length
;
if
(
strncmp
(
host
,
"http://"
,
7
)
==
0
)
host
+=
7
;
if
(
*
host
==
'['
)
{
if
(
!
(
host_end
=
strchr
(
host
,
']'
)))
return
NULL
;
host_end
++
;
}
else
host_end
=
host
;
for
(;
*
host_end
&&
*
host_end
!=
'/'
;
host_end
++
)
;
length
=
host_end
-
host
;
if
(
length
>=
buffer_size
)
return
NULL
;
memcpy
(
buffer
,
host
,
length
);
buffer
[
length
]
=
'\0'
;
return
buffer
;
}
URL
url_http_open
(
char
*
name
)
{
URL_http
*
url
;
SOCKET
fd
;
char
*
host
,
*
path
=
NULL
,
*
p
;
char
*
host
,
*
p
;
unsigned
short
port
;
char
buff
[
BUFSIZ
];
char
wwwserver
[
256
];
...
...
@@ -125,39 +151,17 @@ URL url_http_open(char *name)
/* private members */
url
->
fp
=
NULL
;
if
(
get_http_url_host_port
(
name
,
wwwserver
,
sizeof
wwwserver
)
==
NULL
)
return
NULL
;
if
(
url_http_proxy_host
)
{
char
*
q
;
int
len
;
host
=
url_http_proxy_host
;
port
=
url_http_proxy_port
;
p
=
name
;
if
(
strncmp
(
p
,
"http://"
,
7
)
==
0
)
p
+=
7
;
if
(
p
[
0
]
==
'['
)
{
if
(
!
(
q
=
strchr
(
p
,
']'
)))
return
NULL
;
*
q
=
'\0'
;
++
p
;
}
else
for
(
q
=
p
;
*
q
&&
*
q
!=
':'
&&
*
q
!=
'/'
;
q
++
)
;
len
=
q
-
p
;
if
(
len
>=
sizeof
(
wwwserver
)
-
1
)
{
/* What?? */
strcpy
(
wwwserver
,
"localhost"
);
}
else
{
strncpy
(
wwwserver
,
p
,
len
);
}
}
else
{
if
(
strncmp
(
name
,
"http://"
,
7
)
==
0
)
name
+=
7
;
n
=
strlen
(
name
);
if
(
n
+
REQUEST_OFFSET
>=
BUFSIZ
)
n
=
strlen
(
wwwserver
);
if
(
n
+
REQUEST_OFFSET
>=
sizeof
buff
)
{
url_http_close
((
URL
)
url
);
url_errno
=
URLERR_URLTOOLONG
;
...
...
@@ -165,42 +169,34 @@ URL url_http_open(char *name)
return
NULL
;
}
memcpy
(
buff
,
name
,
n
+
1
);
memcpy
(
buff
,
wwwserver
,
n
+
1
);
host
=
buff
;
if
(
host
[
0
]
==
'['
)
{
++
host
;
if
(
!
(
p
=
strchr
(
host
,
']'
)))
return
NULL
;
*
p
=
'\0'
;
++
host
;
++
p
;
*
p
++
=
'\0'
;
/* terminate `host' string */
}
else
for
(
p
=
host
;
*
p
&&
*
p
!=
':'
&&
*
p
!=
'/'
;
p
++
)
for
(
p
=
host
;
*
p
&&
*
p
!=
':'
;
p
++
)
;
if
(
*
p
==
':'
)
{
char
*
pp
;
*
p
++
=
'\0'
;
/* terminate `host' string */
port
=
atoi
(
p
);
pp
=
strchr
(
p
,
'/'
);
if
(
pp
==
NULL
)
p
[
0
]
=
'\0'
;
else
p
=
pp
;
}
else
port
=
80
;
path
=
p
;
if
(
*
path
==
'\0'
)
*
(
path
+
1
)
=
'\0'
;
*
path
=
'\0'
;
/* terminate `host' string */
strncpy
(
wwwserver
,
host
,
sizeof
(
wwwserver
));
if
(
strncmp
(
name
,
"http://"
,
7
)
==
0
)
name
+=
7
;
if
((
p
=
strchr
(
name
,
'/'
))
==
NULL
)
name
=
"/"
;
else
name
=
p
;
}
#ifdef DEBUG
...
...
@@ -246,13 +242,7 @@ URL url_http_open(char *name)
return
NULL
;
}
if
(
url_http_proxy_host
)
sprintf
(
buff
,
"GET %s HTTP/1.0
\r\n
"
,
name
);
else
{
*
path
=
'/'
;
sprintf
(
buff
,
"GET %s HTTP/1.0
\r\n
"
,
path
);
}
sprintf
(
buff
,
"GET %s HTTP/1.0
\r\n
"
,
name
);
socket_write
(
fd
,
buff
,
(
long
)
strlen
(
buff
));
#ifdef DEBUG
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment