Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongoose
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esp
mongoose
Commits
50a889da
Commit
50a889da
authored
Jun 04, 2014
by
Sergey Lyubka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inlined parse_url()
parent
0ff07884
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
27 deletions
+8
-27
mongoose.c
mongoose.c
+8
-27
No files found.
mongoose.c
View file @
50a889da
...
@@ -3995,29 +3995,6 @@ static void handle_ssi_request(struct connection *conn, const char *path) {
...
@@ -3995,29 +3995,6 @@ static void handle_ssi_request(struct connection *conn, const char *path) {
}
}
#endif
#endif
static
int
parse_url
(
const
char
*
url
,
char
*
proto
,
size_t
plen
,
char
*
host
,
size_t
hlen
,
unsigned
short
*
port
)
{
int
n
;
char
fmt1
[
100
],
fmt2
[
100
],
fmt3
[
100
];
*
port
=
80
;
proto
[
0
]
=
host
[
0
]
=
'\0'
;
snprintf
(
fmt1
,
sizeof
(
fmt1
),
"%%%zu[a-z]://%%%zu[^: ]:%%hu%%n"
,
plen
,
hlen
);
snprintf
(
fmt2
,
sizeof
(
fmt2
),
"%%%zu[a-z]://%%%zu[^/ ]%%n"
,
plen
,
hlen
);
snprintf
(
fmt3
,
sizeof
(
fmt3
),
"%%%zu[^: ]:%%hu%%n"
,
hlen
);
if
(
sscanf
(
url
,
fmt1
,
proto
,
host
,
port
,
&
n
)
==
3
||
sscanf
(
url
,
fmt2
,
proto
,
host
,
&
n
)
==
2
)
{
return
n
;
}
else
if
(
sscanf
(
url
,
fmt3
,
host
,
port
,
&
n
)
==
2
)
{
proto
[
0
]
=
'\0'
;
return
n
;
}
return
0
;
}
static
void
proxy_request
(
struct
ns_connection
*
pc
,
struct
mg_connection
*
c
)
{
static
void
proxy_request
(
struct
ns_connection
*
pc
,
struct
mg_connection
*
c
)
{
int
i
,
sent_close_header
=
0
;
int
i
,
sent_close_header
=
0
;
...
@@ -4047,11 +4024,16 @@ static void proxify_connection(struct connection *conn) {
...
@@ -4047,11 +4024,16 @@ static void proxify_connection(struct connection *conn) {
unsigned
short
port
=
80
;
unsigned
short
port
=
80
;
struct
mg_connection
*
c
=
&
conn
->
mg_conn
;
struct
mg_connection
*
c
=
&
conn
->
mg_conn
;
struct
ns_server
*
server
=
&
conn
->
server
->
ns_server
;
struct
ns_server
*
server
=
&
conn
->
server
->
ns_server
;
struct
ns_connection
*
pc
;
struct
ns_connection
*
pc
=
NULL
;
int
n
,
use_ssl
;
int
n
=
0
,
use_ssl
=
0
;
const
char
*
url
=
c
->
uri
;
proto
[
0
]
=
host
[
0
]
=
cert
[
0
]
=
'\0'
;
proto
[
0
]
=
host
[
0
]
=
cert
[
0
]
=
'\0'
;
n
=
parse_url
(
c
->
uri
,
proto
,
sizeof
(
proto
),
host
,
sizeof
(
host
),
&
port
);
if
(
sscanf
(
url
,
"%499[^: ]:%hu%n"
,
host
,
&
port
,
&
n
)
!=
2
&&
sscanf
(
url
,
"%9[a-z]://%499[^: ]:%hu%n"
,
proto
,
host
,
&
port
,
&
n
)
!=
3
&&
sscanf
(
url
,
"%9[a-z]://%499[^/ ]%n"
,
proto
,
host
,
&
n
)
!=
2
)
{
n
=
0
;
}
#ifdef NS_ENABLE_SSL
#ifdef NS_ENABLE_SSL
// Find out whether we should be in the MITM mode
// Find out whether we should be in the MITM mode
...
@@ -4070,7 +4052,6 @@ static void proxify_connection(struct connection *conn) {
...
@@ -4070,7 +4052,6 @@ static void proxify_connection(struct connection *conn) {
#endif
#endif
use_ssl
=
port
!=
80
&&
cert
[
0
]
!=
'\0'
;
use_ssl
=
port
!=
80
&&
cert
[
0
]
!=
'\0'
;
if
(
n
>
0
&&
if
(
n
>
0
&&
(
pc
=
ns_connect
(
server
,
host
,
port
,
use_ssl
,
conn
))
!=
NULL
)
{
(
pc
=
ns_connect
(
server
,
host
,
port
,
use_ssl
,
conn
))
!=
NULL
)
{
// Interlink two connections
// Interlink two connections
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment