Commit 5ecb5082 authored by jehan's avatar jehan
Browse files

rework content type header

parent 555f3648
......@@ -424,11 +424,8 @@ scope{int is_value; char* gen_value_string;}
$ret=NULL;
}
};
gen_value
: gen_value_token | quoted_string;
gen_value_token
: (alphanum | mark | PERCENT | PLUS | BQUOTE | SLASH)+;
gen_value
: token | quoted_string;
quoted_string
options { greedy = false; }
......@@ -793,9 +790,16 @@ media_type
: m_type {belle_sip_header_content_type_set_type($header_content_type::current,(const char*)$m_type.text->chars);}
slash
m_subtype {belle_sip_header_content_type_set_subtype($header_content_type::current,(const char*)$m_subtype.text->chars);}
(semi generic_param [BELLE_SIP_PARAMETERS($header_content_type::current)])*;
(semi type_param)? (semi generic_param [BELLE_SIP_PARAMETERS($header_content_type::current)])*;
m_type
: token; /* discrete_type | composite_type;
: token;
type_param: {IS_TOKEN(type)}? token equal type_param_value;
type_param_value : m_type slash m_subtype {belle_sip_parameters_set_parameter(BELLE_SIP_PARAMETERS($header_content_type::current)
,"type"
,(const char*)$type_param_value.text->chars);};
/* discrete_type | composite_type;
discrete_type
: 'text' | 'image' | 'audio' | 'video'
| 'application' | extension_token;
......
......@@ -346,6 +346,23 @@ static void test_content_type_header(void) {
L_content_type = belle_sip_header_content_type_parse(l_raw_header);
belle_sip_free(l_raw_header);
belle_sip_object_unref(BELLE_SIP_OBJECT(L_content_type));
L_content_type = belle_sip_header_content_type_parse("Content-Type: multipart/related; type=application/rlmi+xml");
l_raw_header = belle_sip_object_to_string(BELLE_SIP_OBJECT(L_content_type));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_content_type));
L_tmp = belle_sip_header_content_type_parse(l_raw_header);
L_content_type = BELLE_SIP_HEADER_CONTENT_TYPE(belle_sip_object_clone(BELLE_SIP_OBJECT(L_tmp)));
belle_sip_object_unref(BELLE_SIP_OBJECT(L_tmp));
belle_sip_free(l_raw_header);
BC_ASSERT_STRING_EQUAL(belle_sip_header_content_type_get_type(L_content_type),"multipart");
BC_ASSERT_STRING_EQUAL(belle_sip_header_content_type_get_subtype(L_content_type),"related");
BC_ASSERT_STRING_EQUAL(belle_sip_parameters_get_parameter(BELLE_SIP_PARAMETERS(L_content_type),"type"),"application/rlmi+xml");
belle_sip_object_unref(BELLE_SIP_OBJECT(L_content_type));
BC_ASSERT_PTR_NULL(belle_sip_header_content_type_parse("nimportequoi"));
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment