Skip to content
GitLab
Explore
Sign in
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
3efeb147
Commit
3efeb147
authored
5 years ago
by
Joshua Colp
Committed by
Gerrit Code Review
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge "res_pjsip_messaging: Allow Content-Type to be overridden" into 17
parents
e7e65588
ef5702ce
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
res/res_pjsip_messaging.c
+33
-5
33 additions, 5 deletions
res/res_pjsip_messaging.c
with
33 additions
and
5 deletions
res/res_pjsip_messaging.c
+
33
−
5
View file @
3efeb147
...
...
@@ -316,10 +316,7 @@ static int is_msg_var_blocked(const char *name)
{
int
i
;
/*
* Don't block Content-Type or Max-Forwards headers because the
* user can override them.
*/
/* Don't block the Max-Forwards header because the user can override it */
static
const
char
*
hdr
[]
=
{
"To"
,
"From"
,
...
...
@@ -330,6 +327,7 @@ static int is_msg_var_blocked(const char *name)
"CSeq"
,
"Allow"
,
"Content-Length"
,
"Content-Type"
,
"Request-URI"
,
};
...
...
@@ -635,11 +633,40 @@ static struct msg_data *msg_data_create(const struct ast_msg *msg, const char *t
return
mdata
;
}
static
void
update_content_type
(
pjsip_tx_data
*
tdata
,
struct
ast_msg
*
msg
,
struct
ast_sip_body
*
body
)
{
static
const
pj_str_t
CONTENT_TYPE
=
{
"Content-Type"
,
sizeof
(
"Content-Type"
)
-
1
};
const
char
*
content_type
=
ast_msg_get_var
(
msg
,
pj_strbuf
(
&
CONTENT_TYPE
));
if
(
content_type
)
{
pj_str_t
type
,
subtype
;
pjsip_ctype_hdr
*
parsed
;
/* Let pjsip do the parsing for us */
parsed
=
pjsip_parse_hdr
(
tdata
->
pool
,
&
CONTENT_TYPE
,
ast_strdupa
(
content_type
),
strlen
(
content_type
),
NULL
);
if
(
!
parsed
)
{
ast_log
(
LOG_WARNING
,
"Failed to parse '%s' as a content type. Using text/plain
\n
"
,
content_type
);
return
;
}
/* We need to turn type and subtype into zero-terminated strings */
pj_strdup_with_null
(
tdata
->
pool
,
&
type
,
&
parsed
->
media
.
type
);
pj_strdup_with_null
(
tdata
->
pool
,
&
subtype
,
&
parsed
->
media
.
subtype
);
body
->
type
=
pj_strbuf
(
&
type
);
body
->
subtype
=
pj_strbuf
(
&
subtype
);
}
}
static
int
msg_send
(
void
*
data
)
{
struct
msg_data
*
mdata
=
data
;
/* The caller holds a reference */
const
struct
ast_sip_body
body
=
{
struct
ast_sip_body
body
=
{
.
type
=
"text"
,
.
subtype
=
"plain"
,
.
body_text
=
ast_msg_get_body
(
mdata
->
msg
)
...
...
@@ -664,6 +691,7 @@ static int msg_send(void *data)
update_to
(
tdata
,
mdata
->
to
);
update_from
(
tdata
,
mdata
->
from
);
update_content_type
(
tdata
,
mdata
->
msg
,
&
body
);
if
(
ast_sip_add_body
(
tdata
,
&
body
))
{
pjsip_tx_data_dec_ref
(
tdata
);
...
...
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