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
7900256c
Commit
7900256c
authored
11 years ago
by
Andy Green
Browse files
Options
Downloads
Patches
Plain Diff
allow other headers in http send file
Signed-off-by:
Andy Green
<
andy.green@linaro.org
>
parent
84fd949e
No related branches found
No related tags found
No related merge requests found
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
changelog
+11
-0
11 additions, 0 deletions
changelog
lib/lextable.h
+261
-166
261 additions, 166 deletions
lib/lextable.h
lib/libwebsockets.h
+1
-1
1 addition, 1 deletion
lib/libwebsockets.h
lib/output.c
+10
-2
10 additions, 2 deletions
lib/output.c
test-server/test-server.c
+1
-1
1 addition, 1 deletion
test-server/test-server.c
with
284 additions
and
170 deletions
changelog
+
11
−
0
View file @
7900256c
Changelog
---------
(since v1.23)
User api changes
----------------
Extra optional argument to libwebsockets_serve_http_file() allows injecion
of HTTP headers into the canned response. Eg, cookies may be added like
that without getting involved in having to send the header by hand.
v1.23-chrome32-firefox24
========================
...
...
This diff is collapsed.
Click to expand it.
lib/lextable.h
+
261
−
166
View file @
7900256c
This diff is collapsed.
Click to expand it.
lib/libwebsockets.h
+
1
−
1
View file @
7900256c
...
...
@@ -922,7 +922,7 @@ libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf, size_t len,
LWS_VISIBLE
LWS_EXTERN
int
libwebsockets_serve_http_file
(
struct
libwebsocket_context
*
context
,
struct
libwebsocket
*
wsi
,
const
char
*
file
,
const
char
*
content_type
);
const
char
*
content_type
,
const
char
*
other_headers
);
LWS_VISIBLE
LWS_EXTERN
int
libwebsockets_serve_http_file_fragment
(
struct
libwebsocket_context
*
context
,
struct
libwebsocket
*
wsi
);
...
...
This diff is collapsed.
Click to expand it.
lib/output.c
+
10
−
2
View file @
7900256c
...
...
@@ -648,6 +648,7 @@ LWS_VISIBLE int libwebsockets_serve_http_file_fragment(
* @wsi: Websocket instance (available from user callback)
* @file: The file to issue over http
* @content_type: The http content type, eg, text/html
* @other_headers: NULL or pointer to \0-terminated other header string
*
* This function is intended to be called from the callback in response
* to http requests from the client. It allows the callback to issue
...
...
@@ -659,13 +660,15 @@ LWS_VISIBLE int libwebsockets_serve_http_file_fragment(
* the wsi should be left alone.
*/
LWS_VISIBLE
int
libwebsockets_serve_http_file
(
struct
libwebsocket_context
*
context
,
LWS_VISIBLE
int
libwebsockets_serve_http_file
(
struct
libwebsocket_context
*
context
,
struct
libwebsocket
*
wsi
,
const
char
*
file
,
const
char
*
content_type
)
const
char
*
content_type
,
const
char
*
other_headers
)
{
struct
stat
stat_buf
;
unsigned
char
*
p
=
context
->
service_buffer
;
int
ret
=
0
;
int
n
;
wsi
->
u
.
http
.
fd
=
open
(
file
,
O_RDONLY
#ifdef WIN32
...
...
@@ -691,6 +694,11 @@ LWS_VISIBLE int libwebsockets_serve_http_file(struct libwebsocket_context *conte
p
+=
sprintf
((
char
*
)
p
,
"HTTP/1.0 200 OK
\x0d\x0a
Server: libwebsockets
\x0d\x0a
""Content-Type: %s
\x0d\x0a
"
,
content_type
);
if
(
other_headers
)
{
n
=
strlen
(
other_headers
);
memcpy
(
p
,
other_headers
,
n
);
p
+=
n
;
}
p
+=
sprintf
((
char
*
)
p
,
"Content-Length: %u
\x0d\x0a\x0d\x0a
"
,
(
unsigned
int
)
stat_buf
.
st_size
);
...
...
This diff is collapsed.
Click to expand it.
test-server/test-server.c
+
1
−
1
View file @
7900256c
...
...
@@ -201,7 +201,7 @@ static int callback_http(struct libwebsocket_context *context,
sprintf
(
buf
,
"%s%s"
,
resource_path
,
whitelist
[
n
].
urlpath
);
if
(
libwebsockets_serve_http_file
(
context
,
wsi
,
buf
,
whitelist
[
n
].
mimetype
))
if
(
libwebsockets_serve_http_file
(
context
,
wsi
,
buf
,
whitelist
[
n
].
mimetype
,
NULL
))
return
-
1
;
/* through completion or error, close the socket */
/*
...
...
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