Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libwebsockets
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
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Fork
libwebsockets
Commits
a177285b
Commit
a177285b
authored
7 years ago
by
Andy Green
Browse files
Options
Downloads
Patches
Plain Diff
cgi: fix QUERY_STRING
parent
85277640
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/core/private.h
+5
-0
5 additions, 0 deletions
lib/core/private.h
lib/roles/cgi/cgi-server.c
+22
-18
22 additions, 18 deletions
lib/roles/cgi/cgi-server.c
lib/roles/http/client/client-handshake.c
+1
-1
1 addition, 1 deletion
lib/roles/http/client/client-handshake.c
with
28 additions
and
19 deletions
lib/core/private.h
+
5
−
0
View file @
a177285b
...
@@ -1705,6 +1705,11 @@ void
...
@@ -1705,6 +1705,11 @@ void
lws_peer_dump_from_wsi
(
struct
lws
*
wsi
);
lws_peer_dump_from_wsi
(
struct
lws
*
wsi
);
#endif
#endif
#ifdef LWS_WITH_HTTP_PROXY
hubbub_error
html_parser_cb
(
const
hubbub_token
*
token
,
void
*
pw
);
#endif
void
void
__lws_remove_from_timeout_list
(
struct
lws
*
wsi
);
__lws_remove_from_timeout_list
(
struct
lws
*
wsi
);
...
...
This diff is collapsed.
Click to expand it.
lib/roles/cgi/cgi-server.c
+
22
−
18
View file @
a177285b
...
@@ -112,10 +112,10 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
...
@@ -112,10 +112,10 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
int
timeout_secs
,
const
struct
lws_protocol_vhost_options
*
mp_cgienv
)
int
timeout_secs
,
const
struct
lws_protocol_vhost_options
*
mp_cgienv
)
{
{
struct
lws_context_per_thread
*
pt
=
&
wsi
->
context
->
pt
[(
int
)
wsi
->
tsi
];
struct
lws_context_per_thread
*
pt
=
&
wsi
->
context
->
pt
[(
int
)
wsi
->
tsi
];
char
*
env_array
[
30
],
cgi_path
[
4
00
],
e
[
1024
],
*
p
=
e
,
char
*
env_array
[
30
],
cgi_path
[
5
00
],
e
[
1024
],
*
p
=
e
,
*
end
=
p
+
sizeof
(
e
)
-
1
,
tok
[
256
],
*
t
,
*
sum
,
*
sumend
;
*
end
=
p
+
sizeof
(
e
)
-
1
,
tok
[
256
],
*
t
,
*
sum
,
*
sumend
;
struct
lws_cgi
*
cgi
;
struct
lws_cgi
*
cgi
;
int
n
,
m
=
0
,
i
,
uritok
=
-
1
;
int
n
,
m
=
0
,
i
,
uritok
=
-
1
,
c
;
/*
/*
* give the master wsi a cgi struct
* give the master wsi a cgi struct
...
@@ -217,7 +217,7 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
...
@@ -217,7 +217,7 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
};
};
static
const
char
*
const
meth_names
[]
=
{
static
const
char
*
const
meth_names
[]
=
{
"GET"
,
"POST"
,
"OPTIONS"
,
"PUT"
,
"PATCH"
,
"DELETE"
,
"GET"
,
"POST"
,
"OPTIONS"
,
"PUT"
,
"PATCH"
,
"DELETE"
,
"CONNECT"
,
":path"
"CONNECT"
,
"HEAD"
,
":path"
};
};
if
(
script_uri_path_len
>=
0
)
if
(
script_uri_path_len
>=
0
)
...
@@ -233,34 +233,28 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
...
@@ -233,34 +233,28 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
// if (script_uri_path_len < 0)
// if (script_uri_path_len < 0)
// uritok = 0;
// uritok = 0;
if
(
uritok
>=
0
)
{
lws_snprintf
(
cgi_path
,
sizeof
(
cgi_path
)
-
1
,
"REQUEST_URI=%s"
,
lws_hdr_simple_ptr
(
wsi
,
uritok
));
cgi_path
[
sizeof
(
cgi_path
)
-
1
]
=
'\0'
;
env_array
[
n
++
]
=
cgi_path
;
}
if
(
m
>=
0
)
{
if
(
m
>=
0
)
{
env_array
[
n
++
]
=
p
;
env_array
[
n
++
]
=
p
;
if
(
m
<
8
)
{
if
(
m
<
8
)
{
p
+=
lws_snprintf
(
p
,
end
-
p
,
p
+=
lws_snprintf
(
p
,
end
-
p
,
"REQUEST_METHOD=%s"
,
"REQUEST_METHOD=%s"
,
meth_names
[
m
]);
meth_names
[
m
]);
sum
+=
lws_snprintf
(
sum
,
sumend
-
sum
,
"%s "
,
meth_names
[
m
]);
sum
+=
lws_snprintf
(
sum
,
sumend
-
sum
,
"%s "
,
meth_names
[
m
]);
}
else
{
}
else
{
p
+=
lws_snprintf
(
p
,
end
-
p
,
p
+=
lws_snprintf
(
p
,
end
-
p
,
"REQUEST_METHOD=%s"
,
"REQUEST_METHOD=%s"
,
lws_hdr_simple_ptr
(
wsi
,
WSI_TOKEN_HTTP_COLON_METHOD
));
lws_hdr_simple_ptr
(
wsi
,
WSI_TOKEN_HTTP_COLON_METHOD
));
sum
+=
lws_snprintf
(
sum
,
sumend
-
sum
,
"%s "
,
sum
+=
lws_snprintf
(
sum
,
sumend
-
sum
,
"%s "
,
lws_hdr_simple_ptr
(
wsi
,
WSI_TOKEN_HTTP_COLON_METHOD
));
lws_hdr_simple_ptr
(
wsi
,
WSI_TOKEN_HTTP_COLON_METHOD
));
}
}
p
++
;
p
++
;
}
}
if
(
uritok
>=
0
)
if
(
uritok
>=
0
)
sum
+=
lws_snprintf
(
sum
,
sumend
-
sum
,
"%s "
,
sum
+=
lws_snprintf
(
sum
,
sumend
-
sum
,
"%s "
,
lws_hdr_simple_ptr
(
wsi
,
uritok
));
lws_hdr_simple_ptr
(
wsi
,
uritok
));
env_array
[
n
++
]
=
p
;
env_array
[
n
++
]
=
p
;
p
+=
lws_snprintf
(
p
,
end
-
p
,
"QUERY_STRING="
);
p
+=
lws_snprintf
(
p
,
end
-
p
,
"QUERY_STRING="
);
...
@@ -287,13 +281,23 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
...
@@ -287,13 +281,23 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
p
--
;
p
--
;
*
p
++
=
'\0'
;
*
p
++
=
'\0'
;
if
(
uritok
>=
0
)
{
strcpy
(
cgi_path
,
"REQUEST_URI="
);
c
=
lws_hdr_copy
(
wsi
,
cgi_path
+
12
,
sizeof
(
cgi_path
)
-
12
,
uritok
);
if
(
c
<
0
)
goto
bail3
;
cgi_path
[
sizeof
(
cgi_path
)
-
1
]
=
'\0'
;
env_array
[
n
++
]
=
cgi_path
;
}
sum
+=
lws_snprintf
(
sum
,
sumend
-
sum
,
"%s"
,
env_array
[
n
-
1
]);
sum
+=
lws_snprintf
(
sum
,
sumend
-
sum
,
"%s"
,
env_array
[
n
-
1
]);
if
(
script_uri_path_len
>=
0
)
{
if
(
script_uri_path_len
>=
0
)
{
env_array
[
n
++
]
=
p
;
env_array
[
n
++
]
=
p
;
p
+=
lws_snprintf
(
p
,
end
-
p
,
"PATH_INFO=%s"
,
p
+=
lws_snprintf
(
p
,
end
-
p
,
"PATH_INFO=%s"
,
lws_hdr_simple_ptr
(
wsi
,
uritok
)
+
cgi_path
+
12
+
script_uri_path_len
);
script_uri_path_len
);
p
++
;
p
++
;
}
}
}
}
...
@@ -352,7 +356,7 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
...
@@ -352,7 +356,7 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
env_array
[
n
++
]
=
p
;
env_array
[
n
++
]
=
p
;
p
+=
lws_snprintf
(
p
,
end
-
p
,
"%s=%s"
,
mp_cgienv
->
name
,
p
+=
lws_snprintf
(
p
,
end
-
p
,
"%s=%s"
,
mp_cgienv
->
name
,
mp_cgienv
->
value
);
mp_cgienv
->
value
);
lwsl_
debug
(
" Applying mount-specific cgi env '%s'
\n
"
,
lwsl_
info
(
" Applying mount-specific cgi env '%s'
\n
"
,
env_array
[
n
-
1
]);
env_array
[
n
-
1
]);
p
++
;
p
++
;
mp_cgienv
=
mp_cgienv
->
next
;
mp_cgienv
=
mp_cgienv
->
next
;
...
@@ -363,7 +367,7 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
...
@@ -363,7 +367,7 @@ lws_cgi(struct lws *wsi, const char * const *exec_array, int script_uri_path_len
#if 0
#if 0
for (m = 0; m < n; m++)
for (m = 0; m < n; m++)
lwsl_
err
(" %s\n", env_array[m]);
lwsl_
info
(" %s\n", env_array[m]);
#endif
#endif
/*
/*
...
...
This diff is collapsed.
Click to expand it.
lib/roles/http/client/client-handshake.c
+
1
−
1
View file @
a177285b
...
@@ -717,7 +717,7 @@ lws_client_reset(struct lws **pwsi, int ssl, const char *address, int port,
...
@@ -717,7 +717,7 @@ lws_client_reset(struct lws **pwsi, int ssl, const char *address, int port,
}
}
#ifdef LWS_WITH_HTTP_PROXY
#ifdef LWS_WITH_HTTP_PROXY
static
hubbub_error
hubbub_error
html_parser_cb
(
const
hubbub_token
*
token
,
void
*
pw
)
html_parser_cb
(
const
hubbub_token
*
token
,
void
*
pw
)
{
{
struct
lws_rewrite
*
r
=
(
struct
lws_rewrite
*
)
pw
;
struct
lws_rewrite
*
r
=
(
struct
lws_rewrite
*
)
pw
;
...
...
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