Commit 0bd8c119 authored by jehan's avatar jehan
Browse files

make sure header list is reset in function belle_sip_header_xxx_create(from header_address)

parent 4fe7773c
......@@ -378,6 +378,7 @@ BELLE_SIP_PARSE(header_contact)
belle_sip_header_contact_t* belle_sip_header_contact_create (const belle_sip_header_address_t* contact) {
belle_sip_header_contact_t* header = belle_sip_header_contact_new();
_belle_sip_object_copy(BELLE_SIP_OBJECT(header),BELLE_SIP_OBJECT(contact));
belle_sip_header_set_next(BELLE_SIP_HEADER(header),NULL); /*make sure only one header is kept*/
belle_sip_header_set_name(BELLE_SIP_HEADER(header),BELLE_SIP_CONTACT); /*restaure header name*/
return header;
}
......@@ -478,7 +479,7 @@ belle_sip_header_from_t* belle_sip_header_from_create(const belle_sip_header_add
belle_sip_uri_set_port(uri,0);
belle_sip_uri_headers_clean(uri);
}
belle_sip_header_set_next(BELLE_SIP_HEADER(header),NULL); /*make sure only one header is kept*/
belle_sip_header_set_name(BELLE_SIP_HEADER(header),BELLE_SIP_FROM); /*restore header name*/
if (tag) belle_sip_header_from_set_tag(header,tag);
return header;
......@@ -547,6 +548,7 @@ belle_sip_header_to_t* belle_sip_header_to_create(const belle_sip_header_address
belle_sip_uri_set_port(uri,0);
belle_sip_uri_headers_clean(uri);
}
belle_sip_header_set_next(BELLE_SIP_HEADER(header),NULL); /*make sure only one header is kept*/
belle_sip_header_set_name(BELLE_SIP_HEADER(header),BELLE_SIP_TO); /*restaure header name*/
if (tag) belle_sip_header_to_set_tag(header,tag);
return header;
......@@ -898,6 +900,7 @@ BELLE_SIP_PARSE(header_route)
belle_sip_header_route_t* belle_sip_header_route_create(const belle_sip_header_address_t* route) {
belle_sip_header_route_t* header= belle_sip_header_route_new();
_belle_sip_object_copy((belle_sip_object_t*)header,(belle_sip_object_t*)route);
belle_sip_header_set_next(BELLE_SIP_HEADER(header),NULL); /*make sure only one header is kept*/
belle_sip_header_set_name(BELLE_SIP_HEADER(header),BELLE_SIP_ROUTE); /*restore header name*/
return header;
}
......@@ -1535,6 +1538,7 @@ BELLE_SIP_PARSE(header_##name)\
belle_sip_header_##name##_t* belle_sip_header_##name##_create(const belle_sip_header_address_t* address) { \
belle_sip_header_##name##_t* header= belle_sip_header_##name##_new();\
_belle_sip_object_copy((belle_sip_object_t*)header,(belle_sip_object_t*)address);\
belle_sip_header_set_next(BELLE_SIP_HEADER(header),NULL); /*make sure only one header is kept*/\
belle_sip_header_set_name(BELLE_SIP_HEADER(header),header_name); \
return header;\
}
......@@ -1772,6 +1776,7 @@ BELLE_SIP_PARSE(header_p_preferred_identity)
belle_sip_header_p_preferred_identity_t* belle_sip_header_p_preferred_identity_create (const belle_sip_header_address_t* p_preferred_identity) {
belle_sip_header_p_preferred_identity_t* header = belle_sip_header_p_preferred_identity_new();
_belle_sip_object_copy(BELLE_SIP_OBJECT(header),BELLE_SIP_OBJECT(p_preferred_identity));
belle_sip_header_set_next(BELLE_SIP_HEADER(header),NULL); /*make sure only one header is kept*/
belle_sip_header_set_name(BELLE_SIP_HEADER(header),BELLE_SIP_P_PREFERRED_IDENTITY); /*restaure header name*/
return header;
}
......
......@@ -389,6 +389,8 @@ static void test_route_header(void) {
belle_sip_header_route_t* L_next_route;
belle_sip_header_address_t* address = belle_sip_header_address_parse("<sip:212.27.52.5:5060;transport=udp;lr>");
char* l_raw_header;
belle_sip_header_record_route_t* L_record_route;
BC_ASSERT_PTR_NOT_NULL_FATAL(address);
L_route = belle_sip_header_route_create(address);
belle_sip_object_unref(address);
......@@ -419,6 +421,16 @@ static void test_route_header(void) {
L_route=belle_sip_header_route_parse(l_raw_header);
BC_ASSERT_PTR_NOT_NULL(L_route);
if (L_route) belle_sip_object_unref(L_route);
L_record_route = belle_sip_header_record_route_parse("Record-Route: <sip:212.27.52.5:5060;transport=udp;lr>;charset=ISO-8859-4, <sip:212.27.52.5:5060;transport=udp;lr>");
L_route = belle_sip_header_route_create(BELLE_SIP_HEADER_ADDRESS(L_record_route));
L_uri = belle_sip_header_address_get_uri(BELLE_SIP_HEADER_ADDRESS(L_route));
BC_ASSERT_PTR_NULL(belle_sip_header_get_next(BELLE_SIP_HEADER(L_route)));
BC_ASSERT_PTR_NULL(belle_sip_uri_get_user(L_uri));
BC_ASSERT_EQUAL(belle_sip_uri_get_port(L_uri), 5060,int,"%d");
BC_ASSERT_STRING_EQUAL(belle_sip_uri_get_host(L_uri), "212.27.52.5");
belle_sip_object_unref(L_record_route);
belle_sip_object_unref(L_route);
belle_sip_free(l_raw_header);
}
......
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