Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
asterisk
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
Show more breadcrumbs
Voice
asterisk
Commits
600db408
Commit
600db408
authored
6 years ago
by
Joshua C. Colp
Committed by
Gerrit Code Review
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge "http.c: Support separated HTTP request" into 13
parents
9921262c
148ddfba
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main/http.c
+29
-11
29 additions, 11 deletions
main/http.c
with
29 additions
and
11 deletions
main/http.c
+
29
−
11
View file @
600db408
...
...
@@ -84,11 +84,18 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
/*! Maximum application/json or application/x-www-form-urlencoded body content length. */
#if !defined(LOW_MEMORY)
#define MAX_CONTENT_LENGTH 4096
#define MAX_CONTENT_LENGTH 4096
0
#else
#define MAX_CONTENT_LENGTH 1024
#endif
/* !defined(LOW_MEMORY) */
/*! Initial response body length. */
#if !defined(LOW_MEMORY)
#define INITIAL_RESPONSE_BODY_BUFFER 1024
#else
#define INITIAL_RESPONSE_BODY_BUFFER 512
#endif
/* !defined(LOW_MEMORY) */
/*! Maximum line length for HTTP requests. */
#if !defined(LOW_MEMORY)
#define MAX_HTTP_LINE_LENGTH 4096
...
...
@@ -563,7 +570,7 @@ void ast_http_create_response(struct ast_tcptls_session_instance *ser, int statu
{
char
server_name
[
MAX_SERVER_NAME_LENGTH
];
struct
ast_str
*
server_address
=
ast_str_create
(
MAX_SERVER_NAME_LENGTH
);
struct
ast_str
*
out
=
ast_str_create
(
MAX_CONTENT_LENGTH
);
struct
ast_str
*
out
=
ast_str_create
(
INITIAL_RESPONSE_BODY_BUFFER
);
if
(
!
http_header_data
||
!
server_address
||
!
out
)
{
ast_free
(
http_header_data
);
...
...
@@ -922,19 +929,30 @@ void ast_http_body_read_status(struct ast_tcptls_session_instance *ser, int read
static
int
http_body_read_contents
(
struct
ast_tcptls_session_instance
*
ser
,
char
*
buf
,
int
length
,
const
char
*
what_getting
)
{
int
res
;
int
total
=
0
;
/*
* NOTE: Because ser->f is a non-standard FILE *, fread() does not behave as
* documented.
*/
/* Stream is in exclusive mode so we get it all if possible. */
while
(
total
!=
length
)
{
/*
* NOTE: Because ser->f is a non-standard FILE *, fread() does not behave as
* documented.
*/
/* Stay in fread until get all the expected data or timeout. */
res
=
fread
(
buf
,
length
,
1
,
ser
->
f
);
if
(
res
<
1
)
{
ast_log
(
LOG_WARNING
,
"Short HTTP request %s (Wanted %d)
\n
"
,
what_getting
,
length
);
/* Stay in fread until get all the expected data or timeout. */
res
=
fread
(
buf
+
total
,
length
-
total
,
1
,
ser
->
f
);
if
(
res
<=
0
)
{
break
;
}
total
+=
res
;
}
if
(
total
!=
length
)
{
ast_log
(
LOG_WARNING
,
"Wrong HTTP content read. Request %s (Wanted %d, Read %d)
\n
"
,
what_getting
,
length
,
res
);
return
-
1
;
}
return
0
;
}
...
...
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