diff --git a/samples/nksip_pbx/src/nksip_pbx_sipapp.erl b/samples/nksip_pbx/src/nksip_pbx_sipapp.erl index e17cd1f5..06420747 100644 --- a/samples/nksip_pbx/src/nksip_pbx_sipapp.erl +++ b/samples/nksip_pbx/src/nksip_pbx_sipapp.erl @@ -155,7 +155,7 @@ route(ReqId, _Scheme, <<"200">>, _, _From, State) -> route(ReqId, _Scheme, <<"201">>, _, _From, State) -> All = random_list(find_all_except_me(ReqId)), - Opts = [{headers, [{<<"Nksip-Server">>, <<"201">>}]}], + Opts = [{headers, [{<<"nksip-server">>, <<"201">>}]}], Reply = {proxy, take_in_pairs(All), Opts}, {reply, Reply, State}; @@ -270,7 +270,7 @@ find_all() -> %% @doc Gets all registered contacts, excluding the one in `Request' find_all_except_me(ReqId) -> - [From] = nksip_request:header(pbx, ReqId, <<"From">>), + [From] = nksip_request:header(pbx, ReqId, <<"from">>), [{Scheme, User, Domain}] = nksip_parse:aors(From), AOR = {Scheme, User, Domain}, All = [ diff --git a/samples/nksip_tutorial/src/nksip_tutorial.erl b/samples/nksip_tutorial/src/nksip_tutorial.erl index 35903ca7..28671a54 100644 --- a/samples/nksip_tutorial/src/nksip_tutorial.erl +++ b/samples/nksip_tutorial/src/nksip_tutorial.erl @@ -47,15 +47,15 @@ launch() -> ]), {ok,200,[]} = nksip_uac:options(client2, "sip:127.0.0.1:5070", []), - {ok,407,[{reason_phrase,<<"Proxy Authentication Required">>}]} = + {ok,407,[{reason_phrase, <<"Proxy Authentication Required">>}]} = nksip_uac:options(client1, "sip:127.0.0.1", [{fields, [reason_phrase]}]), {ok,200,[]} = nksip_uac:options(client1, "sip:127.0.0.1", [{pass, "1234"}]), {ok,200,[]} = nksip_uac:options(client2, "", [{pass, "1234"}]), - {ok,200,[{<<"Contact">>, [<<";expires=3600">>]}]} = + {ok,200,[{<<"contact">>, [<<";expires=3600">>]}]} = nksip_uac:register(client1, "sip:127.0.0.1", - [{pass, "1234"}, make_contact, {fields, [<<"Contact">>]}]), + [{pass, "1234"}, make_contact, {fields, [<<"contact">>]}]), {ok,200,[]} = nksip_uac:register(client2, "sips:127.0.0.1", [{pass, "1234"}, make_contact]), @@ -66,10 +66,10 @@ launch() -> {ok,200,[]} = nksip_uac:options(client2, "sips:127.0.0.1", []), {ok,407,[]} = nksip_uac:options(client1, "sips:client2@nksip", [{route, ""}]), - {ok,200,[{<<"Nksip-Id">>, [<<"client2">>]}]} = + {ok,200,[{<<"nksip-id">>, [<<"client2">>]}]} = nksip_uac:options(client1, "sips:client2@nksip", [{route, ""}, {pass, "1234"}, - {fields, [<<"Nksip-Id">>]}]), + {fields, [<<"nksip-id">>]}]), {ok,488,[{dialog_id, _}]} = nksip_uac:invite(client2, "sip:client1@nksip", [{route, ""}]), diff --git a/samples/nksip_tutorial/src/nksip_tutorial_sipapp_client.erl b/samples/nksip_tutorial/src/nksip_tutorial_sipapp_client.erl index 7a91d6ee..2aee56a0 100644 --- a/samples/nksip_tutorial/src/nksip_tutorial_sipapp_client.erl +++ b/samples/nksip_tutorial/src/nksip_tutorial_sipapp_client.erl @@ -63,7 +63,7 @@ invite(ReqId, Meta, From, #state{id=AppId}=State) -> %% @doc Called when an OPTIONS is received. %% Reply 200 Ok with a custom header and some options. options(_ReqId, _Meta, _From, #state{id=Id}=State) -> - Headers = [{"NkSip-Id", Id}], + Headers = [{"x-nk-id", Id}], Opts = [make_contact, make_allow, make_accept, make_supported], {reply, {ok, Headers, <<>>, Opts}, State}. diff --git a/src/nksip_auth.erl b/src/nksip_auth.erl index 3f7ab1b6..fc517612 100644 --- a/src/nksip_auth.erl +++ b/src/nksip_auth.erl @@ -28,10 +28,10 @@ -include("nksip.hrl"). --define(RESP_WWW, (<<"WWW-Authenticate">>)). --define(RESP_PROXY, (<<"Proxy-Authenticate">>)). --define(REQ_WWW, (<<"Authorization">>)). --define(REQ_PROXY, (<<"Proxy-Authorization">>)). +-define(RESP_WWW, (<<"www-authenticate">>)). +-define(RESP_PROXY, (<<"proxy-authenticate">>)). +-define(REQ_WWW, (<<"authorization">>)). +-define(REQ_PROXY, (<<"proxy-authorization">>)). %% =================================================================== diff --git a/src/nksip_call_dialog.erl b/src/nksip_call_dialog.erl index 62912828..2617d785 100644 --- a/src/nksip_call_dialog.erl +++ b/src/nksip_call_dialog.erl @@ -281,7 +281,7 @@ route_update(Class, Req, Resp, #dialog{blocked_route_set=false}=Dialog) -> #dialog{app_id=AppId} = Dialog, RouteSet = if Class==uac; Class==proxy -> - RR = nksip_sipmsg:header(Resp, <<"Record-Route">>, uris), + RR = nksip_sipmsg:header(Resp, <<"record-route">>, uris), case lists:reverse(RR) of [] -> []; @@ -295,7 +295,7 @@ route_update(Class, Req, Resp, #dialog{blocked_route_set=false}=Dialog) -> end end; Class==uas -> - RR = nksip_sipmsg:header(Req, <<"Record-Route">>, uris), + RR = nksip_sipmsg:header(Req, <<"record-route">>, uris), case RR of [] -> []; diff --git a/src/nksip_call_fork.erl b/src/nksip_call_fork.erl index 5cd612f7..44a38550 100644 --- a/src/nksip_call_fork.erl +++ b/src/nksip_call_fork.erl @@ -312,7 +312,7 @@ best_response(#fork{request=Req, responses=Resps}, Call) -> ]), case Sorted of [{3999, Best}|_] -> - Names = [<<"WWW-Authenticate">>, <<"Proxy-Authenticate">>], + Names = [<<"www-authenticate">>, <<"proxy-authenticate">>], Headers1 = [ nksip_lib:delete(Best#sipmsg.headers, Names) | [ diff --git a/src/nksip_call_proxy.erl b/src/nksip_call_proxy.erl index f27b01c5..4b679790 100644 --- a/src/nksip_call_proxy.erl +++ b/src/nksip_call_proxy.erl @@ -74,7 +74,7 @@ route(UAS, UriList, ProxyOpts, Call) -> 'ACK' -> {fork, UAS#trans{request=Req3}, UriSet, ProxyOpts1}; _ -> - case nksip_sipmsg:header(Req, <<"Proxy-Require">>, tokens) of + case nksip_sipmsg:header(Req, <<"proxy-require">>, tokens) of [] -> ok; PR -> diff --git a/src/nksip_call_timer.erl b/src/nksip_call_timer.erl index c8d00f96..a1d293c9 100644 --- a/src/nksip_call_timer.erl +++ b/src/nksip_call_timer.erl @@ -112,7 +112,7 @@ uac_received_422(Req, Resp, UAC, Call) -> Iter < ?MAX_422_TRIES of true -> - case nksip_sipmsg:header(Resp, <<"Min-SE">>, integers) of + case nksip_sipmsg:header(Resp, <<"min-se">>, integers) of [RespMinSE] -> #call{opts=#call_opts{app_opts=AppOpts}} = Call, ConfigMinSE = nksip_config:get_cached(min_session_expires, AppOpts), @@ -139,8 +139,8 @@ uac_received_422(Req, Resp, UAC, Call) -> undefined -> SE1 end, Headers1 = nksip_headers:update(Req, [ - {single, <<"Session-Expires">>, SEHd}, - {single, <<"Min-SE">>, NewMinSE} + {single, <<"session-expires">>, SEHd}, + {single, <<"min-se">>, NewMinSE} ]), Req1 = Req#sipmsg{headers=Headers1}, {resend, Req1, Call1}; @@ -182,12 +182,12 @@ uas_check_422(#sipmsg{class={req, Method}}=Req, Call) -> end, case nksip_sipmsg:supported(Req, <<"timer">>) of true -> - {reply, {422, [{<<"Min-SE">>, MinSE}]}, Call1}; + {reply, {422, [{<<"min-se">>, MinSE}]}, Call1}; false -> % No point in returning 422 % Update in case we are a proxy Headers1 = nksip_headers:update(Req, - [{single, <<"Min-SE">>, MinSE}]), + [{single, <<"min-se">>, MinSE}]), {update, Req#sipmsg{headers=Headers1}, Call1} end; _ -> @@ -214,7 +214,7 @@ uas_update_timer( #sipmsg{require=Require} = Resp, #call{opts=#call_opts{app_opts=AppOpts}} = Call, ReqSupport = nksip_sipmsg:supported(Req, <<"timer">>), - ReqMinSE = case nksip_sipmsg:header(Req, <<"Min-SE">>, integers) of + ReqMinSE = case nksip_sipmsg:header(Req, <<"min-se">>, integers) of [ReqMinSE0] -> ReqMinSE0; _ -> 90 end, @@ -236,7 +236,7 @@ uas_update_timer( end, SE_Token = {SE, [{<<"refresher">>, Refresh}]}, Headers1 = nksip_headers:update(Resp, - [{default_single, <<"Session-Expires">>, SE_Token}]), + [{default_single, <<"session-expires">>, SE_Token}]), % Add 'timer' to response's Require only if supported by uac Require1 = case ReqSupport of true -> nksip_lib:store_value(<<"timer">>, Require); @@ -257,7 +257,7 @@ uas_update_timer(_Req, Resp, _Call) -> proxy_request(#sipmsg{class={req, Method}}=Req, Call) when Method=='INVITE'; Method=='UPDATE' -> - ReqMinSE = case nksip_sipmsg:header(Req, <<"Min-SE">>, integers) of + ReqMinSE = case nksip_sipmsg:header(Req, <<"min-se">>, integers) of [ReqMinSE0] -> ReqMinSE0; _ -> 90 end, @@ -275,7 +275,7 @@ proxy_request(#sipmsg{class={req, Method}}=Req, Call) ReqSE -> Req; _ -> - Headers1 = nksip_headers:update(Req, [{single, <<"Session-Expires">>, SE}]), + Headers1 = nksip_headers:update(Req, [{single, <<"session-expires">>, SE}]), Req#sipmsg{headers=Headers1} end; @@ -299,7 +299,7 @@ proxy_response(Req, Resp) -> SE_Token = {nksip_lib:to_binary(SE), [{<<"refresher">>, <<"uac">>}]}, Headers1 = nksip_headers:update(Resp, - [{single, <<"Session-Expires">>, SE_Token}]), + [{single, <<"session-expires">>, SE_Token}]), #sipmsg{require=Require} = Resp, Require1 = nksip_lib:store_value(<<"timer">>, Require), Resp#sipmsg{require=Require1, headers=Headers1}; @@ -314,7 +314,7 @@ proxy_response(Req, Resp) -> %% @private parse(Resp) -> - case catch nksip_parse:header({<<"Session-Expires">>, Resp}) of + case catch nksip_parse:header({<<"session-expires">>, Resp}) of {error, undefied} -> undefined; {SE, Refresh} -> {SE, Refresh}; _ -> invalid diff --git a/src/nksip_call_uac_dialog.erl b/src/nksip_call_uac_dialog.erl index 61362d3b..95e06067 100644 --- a/src/nksip_call_uac_dialog.erl +++ b/src/nksip_call_uac_dialog.erl @@ -570,7 +570,7 @@ generate(Method, Opts, Dialog, Call) -> #invite{request=#sipmsg{headers=Headers}} = Invite, case nksip_lib:extract(Headers, - [<<"Authorization">>, <<"Proxy-Authorization">>]) + [<<"authorization">>, <<"proxy-authorization">>]) of [] -> []; AuthHds -> [{pre_headers, AuthHds}] diff --git a/src/nksip_call_uac_reply.erl b/src/nksip_call_uac_reply.erl index 3c46af3f..0613c91f 100644 --- a/src/nksip_call_uac_reply.erl +++ b/src/nksip_call_uac_reply.erl @@ -141,7 +141,7 @@ fun_response(Resp, Opts) -> [{subscription_id, nksip_subscription:id(Resp)}]; 'PUBLISH' when Code>=200, Code<300 -> Expires = nksip_sipmsg:field(Resp, parsed_expires), - case nksip_sipmsg:header(Resp, <<"SIP-ETag">>) of + case nksip_sipmsg:header(Resp, <<"sip-etag">>) of [SipETag] -> [{sip_etag, SipETag}, {expires, Expires}]; _ -> [] end; diff --git a/src/nksip_call_uas_dialog.erl b/src/nksip_call_uas_dialog.erl index 1e6358b5..64a799ff 100644 --- a/src/nksip_call_uas_dialog.erl +++ b/src/nksip_call_uas_dialog.erl @@ -480,7 +480,7 @@ get_sdp(#sipmsg{body=Body}, #invite{sdp_offer=Offer, sdp_answer=Answer}) -> retry() -> { 500, - [{<<"Retry-After">>, crypto:rand_uniform(0, 11)}], + [{<<"retry-after">>, crypto:rand_uniform(0, 11)}], <<>>, [{reason_phrase, <<"Processing Previous INVITE">>}] }. diff --git a/src/nksip_call_uas_process.erl b/src/nksip_call_uas_process.erl index 118b4957..26098ce0 100644 --- a/src/nksip_call_uas_process.erl +++ b/src/nksip_call_uas_process.erl @@ -179,7 +179,7 @@ method('REGISTER', Req, UAS, Call) -> {value, registrar, Registrar}, {value, req, Req} ], - case nksip_sipmsg:header(Req, <<"Path">>, uris) of + case nksip_sipmsg:header(Req, <<"path">>, uris) of error -> reply(invalid_request, UAS, Call); [] -> @@ -198,7 +198,7 @@ method('PRACK', Req, UAS, Call) -> #sipmsg{dialog_id=DialogId} = Req, #call{trans=Trans} = Call, try - {RSeq, CSeq, Method} = case nksip_sipmsg:header(Req, <<"RAck">>) of + {RSeq, CSeq, Method} = case nksip_sipmsg:header(Req, <<"rack">>) of [RACK] -> case nksip_lib:tokens(RACK) of [RSeqB, CSeqB, MethodB] -> @@ -248,7 +248,7 @@ method('MESSAGE', Req, UAS, Call) -> #sipmsg{expires=Expires, start=Start} = Req, Expired = case is_integer(Expires) of true -> - case nksip_sipmsg:header(Req, <<"Date">>, dates) of + case nksip_sipmsg:header(Req, <<"date">>, dates) of [Date] -> Final = nksip_lib:gmt_to_timestamp(Date) + Expires, case nksip_lib:timestamp() of @@ -269,7 +269,7 @@ method('MESSAGE', Req, UAS, Call) -> process_call(message, Fields, UAS, Call); method('REFER', #sipmsg{headers=Headers}, UAS, Call) -> - case proplists:get_all_values(<<"Refer-To">>, Headers) of + case proplists:get_all_values(<<"refer-to">>, Headers) of [ReferTo] -> Fields = [app_id, aor, dialog_id, subscription_id, {value, refer_to, ReferTo}], @@ -279,7 +279,7 @@ method('REFER', #sipmsg{headers=Headers}, UAS, Call) -> end; method('PUBLISH', Req, UAS, Call) -> - case nksip_sipmsg:header(Req, <<"SIP-If-Match">>) of + case nksip_sipmsg:header(Req, <<"sip-if-match">>) of [Tag] -> ok; _ -> Tag = <<>> end, diff --git a/src/nksip_call_uas_reply.erl b/src/nksip_call_uas_reply.erl index d1f7b057..7836368b 100644 --- a/src/nksip_call_uas_reply.erl +++ b/src/nksip_call_uas_reply.erl @@ -131,7 +131,7 @@ check_prack(Resp, UAS) -> 0 -> crypto:rand_uniform(1, 2147483647); _ -> LastRSeq+1 end, - Headers1 = nksip_headers:update(Resp, [{single, <<"RSeq">>, RSeq}]), + Headers1 = nksip_headers:update(Resp, [{single, <<"rseq">>, RSeq}]), Resp1 = Resp#sipmsg{headers=Headers1}, PRAcks = [{RSeq, CSeq, Method, DialogId}], UAS1 = UAS#trans{rseq=RSeq, pracks=PRAcks}, diff --git a/src/nksip_outbound.erl b/src/nksip_outbound.erl index 5b99f6b8..af81b327 100644 --- a/src/nksip_outbound.erl +++ b/src/nksip_outbound.erl @@ -224,14 +224,14 @@ registrar(Req, Opts) -> <<"NkF", Flow/binary>>, [<<"lr">>, <<"ob">>]), Headers1 = nksip_headers:update(Req, - [{before_single, <<"Path">>, Path}]), + [{before_single, <<"path">>, Path}]), Req1 = Req#sipmsg{headers=Headers1}, {ok, Req1, [{registrar_outbound, true}|Opts]}; [] -> {ok, Req, [{registrar_outbound, false}|Opts]} end; true -> - case nksip_sipmsg:header(Req, <<"Path">>, uris) of + case nksip_sipmsg:header(Req, <<"path">>, uris) of error -> {error, {invalid_request, <<"Invalid Path">>}}; [] -> diff --git a/src/nksip_publish.erl b/src/nksip_publish.erl index 0e252906..a9809bc4 100644 --- a/src/nksip_publish.erl +++ b/src/nksip_publish.erl @@ -117,7 +117,7 @@ make_reg(Body) -> %% @private reply(Tag, Expires) -> - {ok, [{<<"SIP-ETag">>, Tag}], <<>>, [{expires, Expires}]}. + {ok, [{<<"sip-etag">>, Tag}], <<>>, [{expires, Expires}]}. %% @private diff --git a/src/nksip_registrar.erl b/src/nksip_registrar.erl index 6a33f528..ff9b1c71 100644 --- a/src/nksip_registrar.erl +++ b/src/nksip_registrar.erl @@ -359,7 +359,7 @@ update(Req, Times, Opts) -> #sipmsg{app_id=AppId, to=To, contacts=Contacts} = Req, {_, _, Default, Now, _LongNow} = Times, check_several_reg_id(Contacts, Default, false), - Path = case nksip_sipmsg:header(Req, <<"Path">>, uris) of + Path = case nksip_sipmsg:header(Req, <<"path">>, uris) of error -> throw({invalid_request, "Invalid Path"}); Path0 -> Path0 end, @@ -594,7 +594,7 @@ make_contact(#reg_contact{contact=Contact, path=Path}) -> #uri{headers=Headers} = Contact, Route1 = nksip_unparse:uri(Path), Routes2 = list_to_binary(http_uri:encode(binary_to_list(Route1))), - Headers1 = [{<<"Route">>, Routes2}|Headers], + Headers1 = [{<<"route">>, Routes2}|Headers], Contact#uri{headers=Headers1, ext_opts=[], ext_headers=[]}. diff --git a/src/nksip_reply.erl b/src/nksip_reply.erl index a95994fc..623dda08 100644 --- a/src/nksip_reply.erl +++ b/src/nksip_reply.erl @@ -328,7 +328,7 @@ reqreply({method_not_allowed, Methods}) -> Methods1 = nksip_lib:to_binary(Methods), #reqreply{ code = 405, - headers = nksip_headers:new([{single, <<"Allow">>, Methods1}]) + headers = nksip_headers:new([{single, <<"allow">>, Methods1}]) }; reqreply(proxy_authenticate) -> #reqreply{code=407, opts=[make_allow, {make_proxy_auth, from}]}; @@ -342,7 +342,7 @@ reqreply({unsupported_media_type, Types}) -> Types1 = nksip_lib:to_binary(Types), #reqreply{ code=415, - headers = nksip_headers:new([{single, <<"Accept">>, Types1}]) + headers = nksip_headers:new([{single, <<"accept">>, Types1}]) }; reqreply(conditional_request_failed) -> #reqreply{code=412}; @@ -352,7 +352,7 @@ reqreply({unsupported_media_encoding, Types}) -> Types1 = nksip_lib:to_binary(Types), #reqreply{ code = 415, - headers = nksip_headers:new([{single, <<"Accept-Encoding">>, Types1}]) + headers = nksip_headers:new([{single, <<"accept-encoding">>, Types1}]) }; reqreply(unsupported_uri_scheme) -> #reqreply{code=416}; @@ -360,7 +360,7 @@ reqreply({bad_extension, Exts}) -> Exts1 = nksip_lib:to_binary(Exts), #reqreply{ code = 420, - headers = nksip_headers:new([{single, <<"Unsupported">>, Exts1}]) + headers = nksip_headers:new([{single, <<"unsupported">>, Exts1}]) }; reqreply({extension_required, Exts}) -> #reqreply{code=421, opts=[{require, Exts}]}; @@ -368,7 +368,7 @@ reqreply({interval_too_brief, Min}) -> Min1 = nksip_lib:to_binary(Min), #reqreply{ code = 423, - headers = nksip_headers:new([{single, <<"Min-Expires">>, Min1}]) + headers = nksip_headers:new([{single, <<"min-expires">>, Min1}]) }; reqreply(flow_failed) -> #reqreply{code=430}; @@ -391,7 +391,7 @@ reqreply(busy) -> reqreply(request_terminated) -> #reqreply{code=487}; reqreply({not_acceptable, Reason}) -> - #reqreply{code=488, headers=[{<<"Warning">>, nksip_lib:to_binary(Reason)}]}; + #reqreply{code=488, headers=[{<<"warning">>, nksip_lib:to_binary(Reason)}]}; reqreply(bad_event) -> #reqreply{code=489}; reqreply(request_pending) -> diff --git a/src/nksip_sipapp_auto.erl b/src/nksip_sipapp_auto.erl index db3b825f..b631d4fb 100644 --- a/src/nksip_sipapp_auto.erl +++ b/src/nksip_sipapp_auto.erl @@ -420,7 +420,7 @@ launch_register(AppId, Reg)-> } = Reg, Opts1 = [ make_contact, {call_id, CallId}, {cseq, CSeq}, {expires, Interval}, - {fields, [cseq_num, remote, parsed_require, <<"Retry-After">>, <<"Flow-Timer">>]} + {fields, [cseq_num, remote, parsed_require, <<"retry-after">>, <<"flow-timer">>]} | Opts ], Self = self(), @@ -486,7 +486,7 @@ update_register(Reg, Code, Meta, #state{app_id=AppId}) when Code>=200, Code<300 true -> case nksip_transport:get_connected(AppId, Proto, Ip, Port, Res) of [{_, Pid}|_] -> - Secs = case nksip_lib:get_integer(<<"Flow-Timer">>, Meta) of + Secs = case nksip_lib:get_integer(<<"flow-timer">>, Meta) of FT when is_integer(FT), FT > 5 -> FT; _ when Proto==udp -> ?DEFAULT_UDP_KEEPALIVE; _ -> ?DEFAULT_TCP_KEEPALIVE @@ -521,7 +521,7 @@ update_register(Reg, Code, Meta, State) -> MaxTime = nksip_config:get(outbound_max_time), Upper = min(MaxTime, BaseTime*math:pow(2, Fails+1)), Elap = round(crypto:rand_uniform(50, 101) * Upper / 100), - Add = case Code==503 andalso nksip_lib:get_value(<<"Retry-After">>, Meta) of + Add = case Code==503 andalso nksip_lib:get_value(<<"retry-after">>, Meta) of [Retry1] -> case nksip_lib:to_integer(Retry1) of Retry2 when Retry2 > 0 -> Retry2; @@ -595,7 +595,7 @@ update_ping(Ping, Code, Meta, _State) -> undefined -> ok; _ -> gen_server:reply(From, {ok, Ok}) end, - Add = case Code==503 andalso nksip_lib:get_value(<<"Retry-After">>, Meta) of + Add = case Code==503 andalso nksip_lib:get_value(<<"retry-after">>, Meta) of [Retry1] -> case nksip_lib:to_integer(Retry1) of Retry2 when Retry2 > 0 -> Retry2; diff --git a/src/nksip_sipmsg.erl b/src/nksip_sipmsg.erl index af3c905f..b0d1f478 100644 --- a/src/nksip_sipmsg.erl +++ b/src/nksip_sipmsg.erl @@ -102,7 +102,7 @@ field(#sipmsg{class=Class, ruri=RUri, transport=T}=S, Field) -> parsed_require -> S#sipmsg.require; supported -> nksip_lib:bjoin(S#sipmsg.supported); parsed_supported -> S#sipmsg.supported; - allow -> header(S, <<"Allow">>); + allow -> header(S, <<"allow">>); body -> S#sipmsg.body; expires -> nksip_lib:to_binary(S#sipmsg.expires); parsed_expires -> S#sipmsg.expires; @@ -113,11 +113,11 @@ field(#sipmsg{class=Class, ruri=RUri, transport=T}=S, Field) -> reason_phrase -> case Class of {resp, _Code, Reason} -> Reason; _ -> <<>> end; realms -> nksip_auth:realms(S); rseq_num -> - case header(S, <<"RSeq">>, integers) of [RSeq] -> RSeq; _ -> undefined end; + case header(S, <<"rseq">>, integers) of [RSeq] -> RSeq; _ -> undefined end; content_type -> nksip_unparse:token(S#sipmsg.content_type); parsed_content_type -> S#sipmsg.content_type; parsed_rack -> - case header(S, <<"RAck">>) of + case header(S, <<"rack">>) of [RAck] -> case nksip_lib:tokens(RAck) of [RSeq, CSeq, Method] -> @@ -172,19 +172,19 @@ named_fields(#sipmsg{}=SipMsg, Fields) when is_list(Fields) -> header(#sipmsg{headers=Headers}=SipMsg, Name) -> case nksip_lib:to_binary(Name) of - <<"Call-ID">> -> [field(SipMsg, call_id)]; - <<"Via">> -> field(SipMsg, vias); - <<"From">> -> [field(SipMsg, from)]; - <<"To">> -> [field(SipMsg, to)]; - <<"CSeq">> -> [field(SipMsg, cseq)]; - <<"Forwards">> -> [nksip_lib:to_binary(field(SipMsg, forwards))]; - <<"Route">> -> field(SipMsg, routes); - <<"Contact">> -> field(SipMsg, contacts); - <<"Content-Type">> -> [field(SipMsg, content_type)]; - <<"Require">> -> case field(SipMsg, require) of <<>> -> []; R -> [R] end; - <<"Supported">> -> case field(SipMsg, supported) of <<>> -> []; S -> [S] end; - <<"Expires">> -> case field(SipMsg, expires) of <<>> -> []; E -> [E] end; - <<"Event">> -> case field(SipMsg, event) of <<>> -> []; E -> [E] end; + <<"call-id">> -> [field(SipMsg, call_id)]; + <<"via">> -> field(SipMsg, vias); + <<"from">> -> [field(SipMsg, from)]; + <<"to">> -> [field(SipMsg, to)]; + <<"cseq">> -> [field(SipMsg, cseq)]; + <<"forwards">> -> [nksip_lib:to_binary(field(SipMsg, forwards))]; + <<"route">> -> field(SipMsg, routes); + <<"contact">> -> field(SipMsg, contacts); + <<"content-type">> -> [field(SipMsg, content_type)]; + <<"require">> -> case field(SipMsg, require) of <<>> -> []; R -> [R] end; + <<"supported">> -> case field(SipMsg, supported) of <<>> -> []; S -> [S] end; + <<"expires">> -> case field(SipMsg, expires) of <<>> -> []; E -> [E] end; + <<"event">> -> case field(SipMsg, event) of <<>> -> []; E -> [E] end; Name1 -> proplists:get_all_values(Name1, Headers) end. @@ -206,39 +206,39 @@ header(#sipmsg{}=SipMsg, Name, Type) -> %% @private all_headers(SipMsg) -> lists:flatten([ - {<<"Call-ID">>, [field(SipMsg, call_id)]}, - {<<"Via">>, field(SipMsg, vias)}, - {<<"From">>, [field(SipMsg, from)]}, - {<<"To">>, [field(SipMsg, to)]}, - {<<"CSeq">>, [field(SipMsg, cseq)]}, - {<<"Forwards">>, [nksip_lib:to_binary(field(SipMsg, forwards))]}, + {<<"call-id">>, [field(SipMsg, call_id)]}, + {<<"via">>, field(SipMsg, vias)}, + {<<"from">>, [field(SipMsg, from)]}, + {<<"to">>, [field(SipMsg, to)]}, + {<<"cseq">>, [field(SipMsg, cseq)]}, + {<<"forwards">>, [nksip_lib:to_binary(field(SipMsg, forwards))]}, case field(SipMsg, routes) of [] -> []; - Routes -> {<<"Route">>, Routes} + Routes -> {<<"route">>, Routes} end, case field(SipMsg, contacts) of [] -> []; - Contacts -> {<<"Contact">>, Contacts} + Contacts -> {<<"contact">>, Contacts} end, case field(SipMsg, content_type) of <<>> -> []; - ContentType -> {<<"Content-Type">>, ContentType} + ContentType -> {<<"content-type">>, ContentType} end, case field(SipMsg, require) of <<>> -> []; - Require -> {<<"Require">>, Require} + Require -> {<<"require">>, Require} end, case field(SipMsg, supported) of <<>> -> []; - Supported -> {<<"Supported">>, Supported} + Supported -> {<<"supported">>, Supported} end, case field(SipMsg, expires) of <<>> -> []; - Expires -> {<<"Expires">>, Expires} + Expires -> {<<"expires">>, Expires} end, case field(SipMsg, event) of <<>> -> []; - Event -> {<<"Event">>, Event} + Event -> {<<"event">>, Event} end, SipMsg#sipmsg.headers ]). diff --git a/src/nksip_subscription.erl b/src/nksip_subscription.erl index 3901ec19..55547aaf 100644 --- a/src/nksip_subscription.erl +++ b/src/nksip_subscription.erl @@ -232,7 +232,7 @@ get_all(AppId, CallId) -> {terminated, nksip_subscription:terminated_reason()}. notify_status(#sipmsg{}=SipMsg) -> - case nksip_sipmsg:header(SipMsg, <<"Subscription-State">>, tokens) of + case nksip_sipmsg:header(SipMsg, <<"subscription-state">>, tokens) of [{Status, Opts}] -> case nksip_lib:get_list(<<"expires">>, Opts) of "" -> diff --git a/src/nksip_transport_uac.erl b/src/nksip_transport_uac.erl index 314ff681..b68786c5 100644 --- a/src/nksip_transport_uac.erl +++ b/src/nksip_transport_uac.erl @@ -220,8 +220,8 @@ make_request_fun(Req, Dest, GlobalId, Opts) -> opts = [<<"rport">>, {<<"branch">>, Branch}] }, Headers1 = nksip_headers:update(Headers, [ - {before_multi, <<"Record-Route">>, RecordRoute}, - {before_multi, <<"Path">>, Path}]), + {before_multi, <<"record-route">>, RecordRoute}, + {before_multi, <<"path">>, Path}]), Body1 = case Body of #sdp{} = SDP -> nksip_sdp:update_ip(SDP, ListenHost); _ -> Body diff --git a/src/nksip_transport_uas.erl b/src/nksip_transport_uas.erl index e750ddd0..54102d04 100644 --- a/src/nksip_transport_uas.erl +++ b/src/nksip_transport_uas.erl @@ -141,10 +141,10 @@ make_response_fun(RouteHash, Resp, Opts) -> Route end end, - RRs = nksip_sipmsg:header(Resp, <<"Record-Route">>, uris), + RRs = nksip_sipmsg:header(Resp, <<"record-route">>, uris), Routes = lists:map(UpdateRoutes, RRs), Headers1 = nksip_headers:update(Headers, [ - {multi, <<"Record-Route">>, Routes}]), + {multi, <<"record-route">>, Routes}]), Body1 = case Body of #sdp{} = SDP -> nksip_sdp:update_ip(SDP, ListenHost); _ -> Body diff --git a/src/nksip_uac.erl b/src/nksip_uac.erl index 0ff5203a..a9a1c5a3 100644 --- a/src/nksip_uac.erl +++ b/src/nksip_uac.erl @@ -833,7 +833,7 @@ refer(AppId, Dest, Opts) -> <<>> -> {error, invalid_refer_to}; ReferTo -> - Opts1 = [{pre_headers, [{<<"Refer-To">>, ReferTo}]}|Opts], + Opts1 = [{pre_headers, [{<<"refer-to">>, ReferTo}]}|Opts], send_any(AppId, 'REFER', Dest, Opts1) end. @@ -891,7 +891,7 @@ publish(AppId, Dest, Opts) -> % event and expires options are detected later Opts1 = case nksip_lib:get_binary(sip_etag, Opts) of <<>> -> Opts; - ETag -> [{pre_headers, [{<<"SIP-If-Match">>, ETag}]}|Opts] + ETag -> [{pre_headers, [{<<"sip-if-match">>, ETag}]}|Opts] end, Opts2 = [make_supported, make_allow, make_allow_event | Opts1], send_any(AppId, 'PUBLISH', Dest, Opts2). diff --git a/src/nksip_uac_lib.erl b/src/nksip_uac_lib.erl index d37b96f8..3cc24cb2 100644 --- a/src/nksip_uac_lib.erl +++ b/src/nksip_uac_lib.erl @@ -128,14 +128,14 @@ make_cancel(Req, Reason) -> vias = [Via|_], headers = Hds } = Req, - Headers1 = nksip_lib:extract(Hds, <<"Route">>), + Headers1 = nksip_lib:extract(Hds, <<"route">>), Headers2 = case Reason of undefined -> Headers1; Reason -> case nksip_unparse:error_reason(Reason) of error -> Headers1; - BinReason -> [{<<"Reason">>, BinReason}|Headers1] + BinReason -> [{<<"reason">>, BinReason}|Headers1] end end, Req#sipmsg{ @@ -295,7 +295,7 @@ parse_opts([Term|Rest], Req, Opts, AppOpts) -> %% Automatic header generation (replace existing headers) user_agent -> - {write_header(Req, <<"User-Agent">>, <<"NkSIP ", ?VERSION>>), Opts}; + {write_header(Req, <<"user-agent">>, <<"NkSIP ", ?VERSION>>), Opts}; supported -> {Req#sipmsg{supported=?SUPPORTED}, Opts}; allow -> @@ -303,7 +303,7 @@ parse_opts([Term|Rest], Req, Opts, AppOpts) -> true -> <<(?ALLOW)/binary, ", REGISTER">>; false -> ?ALLOW end, - {write_header(Req, <<"Allow">>, Allow), Opts}; + {write_header(Req, <<"allow">>, Allow), Opts}; accept -> Accept = case Req of #sipmsg{class={req, Method}} @@ -312,17 +312,17 @@ parse_opts([Term|Rest], Req, Opts, AppOpts) -> _ -> ?ACCEPT end, - {write_header(Req, <<"Accept">>, Accept), Opts}; + {write_header(Req, <<"accept">>, Accept), Opts}; date -> Date = nksip_lib:to_binary(httpd_util:rfc1123_date()), - {write_header(Req, <<"Date">>, Date), Opts}; + {write_header(Req, <<"date">>, Date), Opts}; allow_event -> case nksip_lib:get_value(event, AppOpts) of undefined -> {Req, Opts}; Events -> AllowEvent = nksip_lib:bjoin(Events), - {write_header(Req, <<"Allow-Event">>, AllowEvent), Opts} + {write_header(Req, <<"allow-event">>, AllowEvent), Opts} end; % Standard headers (replace existing headers) @@ -383,7 +383,7 @@ parse_opts([Term|Rest], Req, Opts, AppOpts) -> {reason, Reason} when is_tuple(Reason) -> case nksip_unparse:error_reason(Reason) of error -> throw({invalid, reason}); - Bin -> {write_header(Req, <<"Reason">>, Bin), Opts} + Bin -> {write_header(Req, <<"reason">>, Bin), Opts} end; {event, Event} -> case nksip_parse:tokens(Event) of @@ -393,7 +393,7 @@ parse_opts([Term|Rest], Req, Opts, AppOpts) -> {subscription_state, ST} when is_tuple(ST) -> case catch nksip_unparse:token(ST) of Bin when is_binary(Bin) -> - {write_header(Req, <<"Subscription-State">>, Bin), Opts}; + {write_header(Req, <<"subscription-state">>, Bin), Opts}; _ -> throw({invalid, subscription_state}) end; @@ -406,14 +406,14 @@ parse_opts([Term|Rest], Req, Opts, AppOpts) -> (Class==uac orelse Class==uas) andalso is_integer(Int) andalso Int >= MinSE -> Token = {Int, [{<<"refresher">>, Class}]}, - {write_header(Req, <<"Session-Expires">>, Token), Opts}; + {write_header(Req, <<"session-expires">>, Token), Opts}; Int when is_integer(Int) andalso Int >= MinSE -> - {write_header(Req, <<"Session-Expires">>, Int), Opts}; + {write_header(Req, <<"session-expires">>, Int), Opts}; _ -> throw({invalid, session_expires}) end; {min_se, MinSE} when is_integer(MinSE), MinSE > 0 -> - {write_header(Req, <<"Min-SE">>, MinSE), Opts}; + {write_header(Req, <<"min-se">>, MinSE), Opts}; % Routes (added before existing ones) {route, Route} -> diff --git a/src/nksip_uas_lib.erl b/src/nksip_uas_lib.erl index 7f8a2179..2e252920 100644 --- a/src/nksip_uas_lib.erl +++ b/src/nksip_uas_lib.erl @@ -167,8 +167,8 @@ response2(Req, Code, Headers, Body, Opts, AppOpts) -> HeaderOps = [ case Code of 100 -> - case nksip_sipmsg:header(Req, <<"Timestamp">>, integers) of - [Time] -> {single, <<"Timestamp">>, Time}; + case nksip_sipmsg:header(Req, <<"timestamp">>, integers) of + [Time] -> {single, <<"timestamp">>, Time}; _ -> none end; _ -> @@ -178,20 +178,20 @@ response2(Req, Code, Headers, Body, Opts, AppOpts) -> undefined -> none; from -> - {multi, <<"WWW-Authenticate">>, + {multi, <<"www-authenticate">>, nksip_auth:make_response(FromDomain, Req)}; Realm -> - {multi, <<"WWW-Authenticate">>, + {multi, <<"www-authenticate">>, nksip_auth:make_response(Realm, Req)} end, case nksip_lib:get_value(make_proxy_auth, Opts) of undefined -> none; from -> - {multi, <<"Proxy-Authenticate">>, + {multi, <<"proxy-authenticate">>, nksip_auth:make_response(FromDomain, Req)}; Realm -> - {multi, <<"Proxy-Authenticate">>, + {multi, <<"proxy-authenticate">>, nksip_auth:make_response(Realm, Req)} end, case MakeAllow of @@ -200,19 +200,19 @@ response2(Req, Code, Headers, Body, Opts, AppOpts) -> true -> <<(?ALLOW)/binary, ",REGISTER">>; false -> ?ALLOW end, - {default_single, <<"Allow">>, Allow}; + {default_single, <<"allow">>, Allow}; false -> none end, case lists:member(make_accept, Opts) of true -> Accept = nksip_lib:get_value(accept, AppOpts, ?ACCEPT), - {default_single, <<"Accept">>, nksip_unparse:token(Accept)}; + {default_single, <<"accept">>, nksip_unparse:token(Accept)}; false -> none end, case lists:member(make_date, Opts) of - true -> {default_single, <<"Date">>, nksip_lib:to_binary( + true -> {default_single, <<"date">>, nksip_lib:to_binary( httpd_util:rfc1123_date())}; false -> none end, @@ -220,16 +220,16 @@ response2(Req, Code, Headers, Body, Opts, AppOpts) -> if Code>100 andalso Code<300 andalso (Method=='INVITE' orelse Method=='NOTIFY') -> - {multi, <<"Record-Route">>, - proplists:get_all_values(<<"Record-Route">>, ReqHeaders)}; + {multi, <<"record-route">>, + proplists:get_all_values(<<"record-route">>, ReqHeaders)}; true -> none end, % Copy Path from Request case Code>=200 andalso Code<300 andalso Method=='REGISTER' of true -> - {multi, <<"Path">>, - proplists:get_all_values(<<"Path">>, ReqHeaders)}; + {multi, <<"path">>, + proplists:get_all_values(<<"path">>, ReqHeaders)}; false -> none end, @@ -239,7 +239,7 @@ response2(Req, Code, Headers, Body, Opts, AppOpts) -> Reason1 -> case nksip_unparse:error_reason(Reason1) of error -> throw(invalid_reason); - Reason2 -> {default_single, <<"Reason">>, Reason2} + Reason2 -> {default_single, <<"reason">>, Reason2} end end, case @@ -251,7 +251,7 @@ response2(Req, Code, Headers, Body, Opts, AppOpts) -> ServiceRoute1 -> case nksip_parse:uris(ServiceRoute1) of error -> throw(invalid_service_route); - ServiceRoute2 -> {default_single, <<"Service-Route">>, ServiceRoute2} + ServiceRoute2 -> {default_single, <<"service-route">>, ServiceRoute2} end end ], diff --git a/test/a_websocket_test.erl b/test/a_websocket_test.erl index 6eaddc2d..08009588 100644 --- a/test/a_websocket_test.erl +++ b/test/a_websocket_test.erl @@ -279,13 +279,13 @@ proxy() -> C2Pub = nksip_sipapp_srv:get_gruu_pub({ws,ua2}), {ok, 200, [{_, [<<"ua2">>]}]} = nksip_uac:options({ws,ua1}, C2Pub, - [{route, ""}, {fields, [<<"Nk-Id">>]}]), + [{route, ""}, {fields, [<<"x-nk-id">>]}]), % The same with our private GRUU C2Priv = nksip_sipapp_srv:get_gruu_temp({ws,ua2}), {ok, 200, [{_, [<<"ua2">>]}]} = nksip_uac:options({ws,ua1}, C2Priv, - [{route, ""}, {fields, [<<"Nk-Id">>]}]), + [{route, ""}, {fields, [<<"x-nk-id">>]}]), % UA3 registers. Its contact is not routable @@ -297,12 +297,12 @@ proxy() -> C3Pub = nksip_sipapp_srv:get_gruu_pub({ws,ua3}), {ok, 200, [{_, [<<"ua3">>]}]} = nksip_uac:options({ws,ua1}, C3Pub, - [{route, ""}, {fields, [<<"Nk-Id">>]}]), + [{route, ""}, {fields, [<<"x-nk-id">>]}]), C3Priv = nksip_sipapp_srv:get_gruu_temp({ws,ua3}), {ok, 200, [{_, [<<"ua3">>]}]} = nksip_uac:options({ws,ua1}, C3Priv, - [{route, ""}, {fields, [<<"Nk-Id">>]}]), + [{route, ""}, {fields, [<<"x-nk-id">>]}]), % Let's stop the transports diff --git a/test/auth_test.erl b/test/auth_test.erl index 39f65201..e535f4be 100644 --- a/test/auth_test.erl +++ b/test/auth_test.erl @@ -116,7 +116,7 @@ invite() -> C3 = {auth, client3}, SipC3 = "sip:127.0.0.1:5072", Ref = make_ref(), - RepHd = {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, self()}))}, + RepHd = {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, self()}))}, % client3 does not support dialog's authentication, only digest is used {ok, 401, [{cseq_num, CSeq}]} = @@ -154,7 +154,7 @@ dialog() -> C2 = {auth, client2}, SipC2 = "sip:127.0.0.1:5071", Ref = make_ref(), - RepHd = {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, self()}))}, + RepHd = {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, self()}))}, {ok, 200, [{dialog_id, DialogId1}]} = nksip_uac:invite(C1, SipC2, [{pass, "1234"}, {headers, [RepHd]}]), ok = nksip_uac:ack(C1, DialogId1, []), @@ -190,7 +190,7 @@ proxy() -> C2 = {auth, client2}, S1 = "sip:127.0.0.1", Ref = make_ref(), - RepHd = {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, self()}))}, + RepHd = {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, self()}))}, % {ok, 407, []} = nksip_uac:register(C1, S1, []), % {ok, 200, []} = nksip_uac:register(C1, S1, [{pass, "1234"}, unregister_all]), diff --git a/test/basic_test.erl b/test/basic_test.erl index 00ca55ac..55799e49 100644 --- a/test/basic_test.erl +++ b/test/basic_test.erl @@ -104,7 +104,7 @@ transport() -> Body = base64:encode(crypto:rand_bytes(100)), Opts1 = [ - {headers, [{<<"Nksip">>, <<"test1">>}, {<<"Nksip-Op">>, <<"reply-request">>}]}, + {headers, [{<<"x-nksip">>, <<"test1">>}, {<<"x-nk-op">>, <<"reply-request">>}]}, {contact, "sip:aaa:123, sips:bbb:321"}, {user_agent, "My SIP"}, {body, Body}, @@ -114,9 +114,9 @@ transport() -> % Req1 is the request as received at the remote party Req1 = binary_to_term(base64:decode(RespBody)), - [<<"My SIP">>] = nksip_sipmsg:header(Req1, <<"User-Agent">>), + [<<"My SIP">>] = nksip_sipmsg:header(Req1, <<"user-agent">>), [<<"">>,<<"">>] = - nksip_sipmsg:header(Req1, <<"Contact">>), + nksip_sipmsg:header(Req1, <<"contact">>), Body = nksip_sipmsg:field(Req1, body), Fields2 = {fields, [parsed_contacts, remote]}, @@ -139,7 +139,7 @@ transport() -> BigBody = base64:encode(crypto:rand_bytes(1000)), BigBodyHash = erlang:phash2(BigBody), Opts4 = [ - {headers, [{<<"Nksip-Op">>, <<"reply-request">>}]}, + {headers, [{<<"x-nk-op">>, <<"reply-request">>}]}, {content_type, <<"nksip/binary">>}, {body, BigBody}, {fields, [body]} @@ -151,7 +151,7 @@ transport() -> % Check local_host is used to generare local Contact, Route headers are received Opts5 = [ - {headers, [{<<"Nksip-Op">>, <<"reply-request">>}]}, + {headers, [{<<"x-nk-op">>, <<"reply-request">>}]}, make_contact, {local_host, "mihost"}, {route, [<<"">>, ", "]}, @@ -170,9 +170,9 @@ transport() -> ] = nksip_sipmsg:fields(Req5, [parsed_contacts, parsed_routes]), {ok, 200, []} = nksip_uac:options(C1, "sip:127.0.0.1", - [{headers, [{<<"Nksip-Op">>, <<"reply-stateless">>}]}]), + [{headers, [{<<"x-nk-op">>, <<"reply-stateless">>}]}]), {ok, 200, []} = nksip_uac:options(C1, "sip:127.0.0.1", - [{headers, [{<<"Nksip-Op">>, <<"reply-stateful">>}]}]), + [{headers, [{<<"x-nk-op">>, <<"reply-stateful">>}]}]), % Cover ip resolution case nksip_uac:options(C1, "", []) of diff --git a/test/event_test.erl b/test/event_test.erl index c64f2e8f..24fb6663 100644 --- a/test/event_test.erl +++ b/test/event_test.erl @@ -85,12 +85,12 @@ basic() -> receive {Ref, {req, Req1}} -> [[<<"myevent1;id=a">>],[<<"myevent1,myevent2,myevent3">>]] = - nksip_sipmsg:fields(Req1, [<<"Event">>, <<"Allow-Event">>]) + nksip_sipmsg:fields(Req1, [<<"event">>, <<"allow-event">>]) after 1000 -> error(event) end, - RepHd = {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}, + RepHd = {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}, {ok, 200, [{subscription_id, Subs1A}]} = nksip_uac:subscribe(C1, SipC2, [{event, "myevent4;id=4;o=2"}, {expires, 1}, {headers, [RepHd]}]), @@ -183,8 +183,8 @@ refresh() -> Ref = make_ref(), Self = self(), Hds = [ - {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}, - {"Nk-Op", "expires-2"} + {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}, + {"x-nk-op", "expires-2"} ], {ok, 200, [{subscription_id, Subs1A}]} = nksip_uac:subscribe(C1, SipC2, [{event, "myevent4"}, {expires, 5}, @@ -239,7 +239,7 @@ dialog() -> {contact, "sip:a@127.0.0.1"}, {fields, [dialog_id]}]), Subs1B = nksip_subscription:remote_id(C1, Subs1A), - RS1 = {"Record-Route", ",,"}, + RS1 = {"record-route", ",,"}, % Now the remote party (the server) sends a NOTIFY, and updates the Route Set {ok, 200, []} = nksip_uac:notify(C2, Subs1B, [{headers, [RS1]}]), @@ -251,7 +251,7 @@ dialog() -> % It sends another NOTIFY, tries to update again the Route Set but it is not accepted. % The remote target is successfully updated - RS2 = {"Record-Route", ""}, + RS2 = {"record-route", ""}, {ok, 200, []} = nksip_uac:notify(C2, Subs1B, [{headers, [RS2]}, {contact, "sip:b@127.0.0.1:5070"}]), [ {local_target, <<"">>}, @@ -323,12 +323,12 @@ out_or_order() -> SipC2 = "sip:127.0.0.1:5070", Self = self(), Ref = make_ref(), - Reply = {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}, + Reply = {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}, CB = {callback, fun(R) -> Self ! {Ref, R} end}, {async, _} = nksip_uac:subscribe(C1, SipC2, [{event, "myevent4"}, CB, async, get_request, - {headers, [Reply, {"Nk-Op", "wait"}]}, + {headers, [Reply, {"x-nk-op", "wait"}]}, {expires, 2}]), % Right after sending the SUBSCRIBE, and before replying with 200 @@ -358,7 +358,7 @@ out_or_order() -> % Another subscription {async, _} = nksip_uac:subscribe(C1, SipC2, [{event, "myevent4"}, CB, async, get_request, - {headers, [Reply, {"Nk-Op", "wait"}]}, + {headers, [Reply, {"x-nk-op", "wait"}]}, {expires, 2}]), RecvReq2 = receive {Ref, {wait, Req2}} -> Req2 after 1000 -> error(fork) @@ -379,12 +379,12 @@ fork() -> SipC2 = "sip:127.0.0.1:5070", Self = self(), Ref = make_ref(), - Reply = {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}, + Reply = {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}, CB = {callback, fun(R) -> Self ! {Ref, R} end}, {async, _} = nksip_uac:subscribe(C1, SipC2, [{event, "myevent4"}, CB, async, get_request, - {headers, [Reply, {"Nk-Op", "wait"}]}, + {headers, [Reply, {"x-nk-op", "wait"}]}, {expires, 2}]), % Right after sending the SUBSCRIBE, and before replying with 200 @@ -436,7 +436,7 @@ make_notify(#sipmsg{to_tag_candidate=ToTag}=Req) -> routes = [], contacts = nksip_parse:uris("sip:127.0.0.1:5070"), expires = 0, - headers = [{<<"Subscription-State">>, <<"active;expires=5">>}], + headers = [{<<"subscription-state">>, <<"active;expires=5">>}], from_tag = ToTag, to_tag = Req#sipmsg.from_tag, transport = undefined diff --git a/test/fork_test.erl b/test/fork_test.erl index d0b03258..8797a9c8 100644 --- a/test/fork_test.erl +++ b/test/fork_test.erl @@ -214,13 +214,13 @@ basic() -> QUri = "sip:qtest@nksip", Ref = make_ref(), Self = self(), - RepHd = {headers, [{"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}]}, + RepHd = {headers, [{<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}]}, % We have to complete the three iterations Body1 = {body, [{clientC3, 300}]}, - Fs = {fields, [<<"Nk-Id">>]}, + Fs = {fields, [<<"x-nk-id">>]}, {ok, 300, Values1} = nksip_uac:invite({fork, client1}, QUri, [Body1, RepHd, Fs]), - [{<<"Nk-Id">>, [<<"clientC3,serverR,server1">>]}] =Values1, + [{<<"x-nk-id">>, [<<"clientC3,serverR,server1">>]}] =Values1, ok = tests_util:wait(Ref, [{clientA1, 580}, {clientB1, 580}, {clientC1, 580}, {clientA2, 580}, {clientB2, 580}, {clientC3, 300}]), @@ -228,13 +228,13 @@ basic() -> % The first 6xx response aborts everything at first iteration Body2 = {body, [{clientA1, 600}]}, {ok, 600, Values2} = nksip_uac:invite({fork, client2}, QUri, [Body2, RepHd, Fs]), - [{<<"Nk-Id">>, [<<"clientA1,serverR,server2">>]}] =Values2, + [{<<"x-nk-id">>, [<<"clientA1,serverR,server2">>]}] =Values2, ok = tests_util:wait(Ref, [{clientA1, 600}, {clientB1, 580}, {clientC1, 580}]), % Aborted in second iteration Body3 = {body, [{clientA1, 505}, {clientB2, 600}]}, {ok, 600, Values3} = nksip_uac:invite({fork, client3}, QUri, [Body3, RepHd, Fs]), - [{<<"Nk-Id">>, [<<"clientB2,serverR,server3">>]}] =Values3, + [{<<"x-nk-id">>, [<<"clientB2,serverR,server3">>]}] =Values3, ok = tests_util:wait(Ref, [{clientA1, 505}, {clientB1, 580}, {clientC1, 580}, {clientA2, 580}, {clientB2, 600}]), ok. @@ -248,7 +248,7 @@ invite1() -> QUri = "sip:qtest@nksip", Ref = make_ref(), Self = self(), - RepHd = {headers, [{"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}]}, + RepHd = {headers, [{<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}]}, Fun1 = {callback, fun({ok, Code, Vs}) -> Self ! {Ref, {code, Code, Vs}} end}, % Test to CANCEL a forked request @@ -310,7 +310,7 @@ invite2() -> QUri = "sip:qtest@nksip", Ref = make_ref(), Self = self(), - RepHd = {headers, [{"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}]}, + RepHd = {headers, [{<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}]}, CB = {callback, fun({ok, Code, _RId}) -> Self ! {Ref, {code, Code}} end}, Body2 = {body, [{clientB1, {503, 500}}, {clientC1, {415, 500}}, {clientC3, {200, 1000}}]}, @@ -354,13 +354,13 @@ invite2() -> ok = nksip_dialog:stop(SR, Dlg_C2_1), % In-dialog OPTIONS - Fs = {fields, [<<"Nk-Id">>]}, + Fs = {fields, [<<"x-nk-id">>]}, {ok, 200, Values3} = nksip_uac:options(C2, Dlg_C2_1, [Fs]), - [{<<"Nk-Id">>, [<<"clientC3,server2">>]}] = Values3, + [{<<"x-nk-id">>, [<<"clientC3,server2">>]}] = Values3, % Remote party in-dialog OPTIONS {ok, 200, Values4} = nksip_uac:options(CC3, Dlg_CC3_1, [Fs]), - [{<<"Nk-Id">>, [<<"client2,server2">>]}] = Values4, + [{<<"x-nk-id">>, [<<"client2,server2">>]}] = Values4, % Dialog state at clientC1, clientC3 and server2 [ @@ -404,7 +404,7 @@ redirect() -> QUri = "sip:qtest@nksip", Ref = make_ref(), Self = self(), - RepHd = [{"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}], + RepHd = [{<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}], not_found = nksip:get_port(other, udp, ipv4), PortD1 = nksip:get_port({fork, clientD1}, udp, ipv4), PortD2 = nksip:get_port({fork, clientD2}, tcp, ipv4), @@ -412,9 +412,9 @@ redirect() -> #uri{domain= <<"127.0.0.1">>, port=PortD2, opts=[{transport, tcp}]}], Body1 = {body, [{clientC1, {redirect, Contacts}}, {clientD2, 570}]}, - Fs = {fields, [<<"Contact">>]}, + Fs = {fields, [<<"contact">>]}, {ok, 300, Values1} = nksip_uac:invite(CA1, QUri, [Body1, {headers, [RepHd]}, Fs]), - [{<<"Contact">>, [C1, C2]}] = Values1, + [{<<"contact">>, [C1, C2]}] = Values1, {match, [LPortD1]} = re:run(C1, <<"^">>, [{capture, all_but_first, list}]), LPortD1 = integer_to_list(PortD1), @@ -440,7 +440,7 @@ multiple_200() -> QUri = "sip:qtest@nksip", Ref = make_ref(), Self = self(), - RepHd = {headers, [{"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}]}, + RepHd = {headers, [{<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}]}, % client1 requests are sent to server1, stateless and record-routing % client1, server1 and serverR will receive three 200 responses diff --git a/test/inline_test.erl b/test/inline_test.erl index 9493dde8..aa7d6afe 100644 --- a/test/inline_test.erl +++ b/test/inline_test.erl @@ -85,9 +85,9 @@ basic() -> {ok, 200, []} = nksip_uac:register(C2, "sip:127.0.0.1", [make_contact]), ok = tests_util:wait(Ref, [{S1, route}, {S1, route}]), - Fs1 = {fields, [<<"Nk-Id">>]}, + Fs1 = {fields, [<<"x-nk-id">>]}, {ok, 200, Values1} = nksip_uac:options(C1, "sip:client2@nksip", [Fs1]), - [{<<"Nk-Id">>, [<<"server1,client2">>]}] = Values1, + [{<<"x-nk-id">>, [<<"server1,client2">>]}] = Values1, ok = tests_util:wait(Ref, [{S1, route}, {C2, options}]), {ok, 480, []} = nksip_uac:options(C2, "sip:client3@nksip", []), @@ -126,7 +126,7 @@ cancel() -> Ref = make_ref(), Pid = self(), nksip_config:put(inline_test, {Ref, Pid}), - Hds = {headers, [{<<"Nk-Op">>, <<"wait">>}]}, + Hds = {headers, [{<<"x-nk-op">>, <<"wait">>}]}, CB = {callback, fun(Term) -> Pid ! {Ref, Term} end}, {async, ReqId} = nksip_uac:invite(C1, "sip:client2@nksip", [async, Hds, CB]), ok = nksip_uac:cancel(C1, ReqId), @@ -148,7 +148,7 @@ auth() -> S1 = "sip:127.0.0.1", nksip_registrar:clear({inline, server1}), - Hd = {headers, [{<<"Nksip-Auth">>, <<"true">>}]}, + Hd = {headers, [{<<"x-nk-auth">>, <<"true">>}]}, {ok, 407, []} = nksip_uac:options(C1, S1, [Hd]), {ok, 200, []} = nksip_uac:options(C1, S1, [Hd, {pass, "1234"}]), diff --git a/test/invite_test.erl b/test/invite_test.erl index cd2a42da..89a31cdd 100644 --- a/test/invite_test.erl +++ b/test/invite_test.erl @@ -72,15 +72,15 @@ cancel() -> C1 = {invite, client1}, Ref = make_ref(), Self = self(), - RepHd = {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}, + RepHd = {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}, Fun = fun({ok, Code, _}) -> Self ! {Ref, Code} end, % Receive generated busy - Hds1 = [{"Nk-Sleep", 300}, {"Nk-Op", busy}, RepHd], + Hds1 = [{"x-nk-sleep", 300}, {"x-nk-op", busy}, RepHd], {ok, 486, _} = nksip_uac:invite(C1, "sip:any@127.0.0.1:5070", [{callback, Fun}, {headers, Hds1}]), - Hds2 = [{"Nk-Sleep", 3000}, {"Nk-Op", ok}, {"Nk-Prov", "true"}, RepHd], + Hds2 = [{"x-nk-sleep", 3000}, {"x-nk-op", ok}, {"x-nk-prov", "true"}, RepHd], Remote = "sip:any@127.0.0.1:5070", % Test manual CANCEL @@ -111,8 +111,8 @@ dialog() -> Ref = make_ref(), Self = self(), SDP = nksip_sdp:new("client1", [{"test", 1234, [{rtpmap, 0, "codec1"}]}]), - RepHd = {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}, - Hds = [{"Nk-Op", answer}, RepHd], + RepHd = {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}, + Hds = [{"x-nk-op", answer}, RepHd], {ok, 200, [{dialog_id, DialogIdA}]} = nksip_uac:invite(C1, "sip:ok@127.0.0.1:5070", [{headers, Hds}, {body, SDP}]), @@ -257,24 +257,24 @@ rr_contact() -> C2 = {invite, client2}, Ref = make_ref(), Self = self(), - RepHd = [{"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}], + RepHd = [{<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}], SDP = nksip_sdp:new("client1", [{"test", 1234, [{rtpmap, 0, "codec1"}, sendrecv]}]), RR = [<<"">>, <<"">>, <<"">>], Hds1 = [ - {"Nk-Op", "answer"}, RepHd, - {"Record-Route", nksip_lib:bjoin(lists:reverse(RR), <<", ">>)}], + {"x-nk-op", "answer"}, RepHd, + {"record-route", nksip_lib:bjoin(lists:reverse(RR), <<", ">>)}], - {ok, 200, [{dialog_id, DialogIdA}, {<<"Record-Route">>, RRH}]} = + {ok, 200, [{dialog_id, DialogIdA}, {<<"record-route">>, RRH}]} = nksip_uac:invite(C1, "sip:ok@127.0.0.1:5070", [{contact, "sip:abc"}, {headers, Hds1}, - {fields, [<<"Record-Route">>]}]), + {fields, [<<"record-route">>]}]), % Test Record-Route is replied RR = lists:reverse(RRH), FunAck = fun({req, ACKReq1}) -> % Test body in ACK, and Route and Contact generated in ACK - RR = nksip_sipmsg:header(ACKReq1, <<"Route">>), - [<<"">>] = nksip_sipmsg:header(ACKReq1, <<"Contact">>), + RR = nksip_sipmsg:header(ACKReq1, <<"route">>), + [<<"">>] = nksip_sipmsg:header(ACKReq1, <<"contact">>), Self ! {Ref, fun_ack_ok} end, async = nksip_uac:ack(C1, DialogIdA, @@ -312,9 +312,9 @@ rr_contact() -> Fun = fun(R) -> case R of {req, Req} -> - RR = nksip_sipmsg:header(Req, <<"Route">>), + RR = nksip_sipmsg:header(Req, <<"route">>), [#uri{user = <<"client1">>, domain = <<"localhost">>, port=5060}] = - nksip_sipmsg:header(Req, <<"Contact">>, uris), + nksip_sipmsg:header(Req, <<"contact">>, uris), Self ! {Ref, req_ok}; {ok, Code, [{dialog_id, _}]} -> if @@ -326,7 +326,7 @@ rr_contact() -> % Reinvite updating SDP SDP2 = nksip_sdp:update(SDP, sendonly), - Hds2 = [{"Nk-Op", increment}, {"Record-Route", ""}, RepHd], + Hds2 = [{"x-nk-op", increment}, {"record-route", ""}, RepHd], {async, _} = nksip_uac:invite(C1, DialogIdA, [ {body, SDP2}, make_contact, async, {callback, Fun}, get_request, {headers, Hds2}]), @@ -334,9 +334,9 @@ rr_contact() -> % Test Route Set cannot change now, it is already answered receive {Ref, 200} -> {req, ACKReq2} = nksip_uac:ack(C1, DialogIdA, [get_request]), - RR = nksip_sipmsg:header(ACKReq2, <<"Route">>), + RR = nksip_sipmsg:header(ACKReq2, <<"route">>), [#uri{user = <<"client1">>, domain = <<"localhost">>, port=5060}] = - nksip_sipmsg:header(ACKReq2, <<"Contact">>, uris), + nksip_sipmsg:header(ACKReq2, <<"contact">>, uris), ok = tests_util:wait(Ref, [req_ok, {client2, ack}, {client2, sdp_update}, @@ -376,7 +376,7 @@ rr_contact() -> % reINVITE from the other party - Hds3 = [{"Nk-Op", increment}, RepHd], + Hds3 = [{"x-nk-op", increment}, RepHd], {ok, 200, [{dialog_id, DialogIdB}]} = nksip_uac:refresh(C2, DialogIdB, [{headers, Hds3}]), ok = nksip_uac:ack(C2, DialogIdB, []), @@ -423,10 +423,10 @@ rr_contact() -> ByeFun = fun(Reply) -> case Reply of {req, ByeReq} -> - RevRR = nksip_sipmsg:header(ByeReq, <<"Route">>), + RevRR = nksip_sipmsg:header(ByeReq, <<"route">>), RR = lists:reverse(RevRR), [<<"">>] = - nksip_sipmsg:header(ByeReq, <<"Contact">>), + nksip_sipmsg:header(ByeReq, <<"contact">>), Self ! {Ref, bye_ok1}; {ok, 200, []} -> Self ! {Ref, bye_ok2} @@ -448,8 +448,8 @@ multiple_uac() -> C2 = {invite, client2}, Ref = make_ref(), Self = self(), - RepHd = {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}, - OpAnswer = {"Nk-Op", answer}, + RepHd = {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}, + OpAnswer = {"x-nk-op", answer}, % Stablish a dialog between C1 and C2, but do not send the ACK % yet, it will stay in accepted_uac state {ok, 200, [{dialog_id, DialogIdA}]} = @@ -478,8 +478,8 @@ multiple_uas() -> C2 = {invite, client2}, Self = self(), Ref = make_ref(), - RepHd = {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}, - Hds = [{"Nk-Op", ok}, RepHd], + RepHd = {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}, + Hds = [{"x-nk-op", ok}, RepHd], % Set a new dialog between C1 and C2 {ok, 200, [{dialog_id, DialogId1A}]} = @@ -510,7 +510,7 @@ multiple_uas() -> % Send a new reinvite, it will spend 300msecs before answering {async, _} = nksip_uac:invite(C1, DialogId1A, [async, {callback, MakeFun(C1)}, get_request, - {headers, [{"Nk-Sleep", 300}|Hds]}]), + {headers, [{"x-nk-sleep", 300}|Hds]}]), ok = tests_util:wait(Ref, [request]), % Wait to be sent % Before the previous invite has been answered, we send a new one @@ -542,7 +542,7 @@ multiple_uas() -> % The remote party (C2) will send a reinvite to the local (C1), % but the response will be delayed 300msecs - Hds2 = [{"Nk", 1}, {"Nk-Prov", "true"}, {"Nk-Sleep", 300}|Hds], + Hds2 = [{"x-nk", 1}, {"x-nk-prov", "true"}, {"x-nk-sleep", 300}|Hds], {async, _} = nksip_uac:invite(C2, DialogId2B, [async, {callback, MakeFun(C2)}, get_request, {headers, Hds2}]), ok = tests_util:wait(Ref, [request, provisional]), @@ -550,7 +550,7 @@ multiple_uas() -> % replies a 491 % {ok, 491, _} = nksip_uac:invite(C1, DialogId2A, [no_dialog, {headers, [{"Nk", 2}]}]), {error, request_pending} = - nksip_uac:invite(C1, DialogId2A, [no_dialog, {headers, [{"Nk", 2}]}]), + nksip_uac:invite(C1, DialogId2A, [no_dialog, {headers, [{"x-nk", 2}]}]), % The previous invite will be answered, and Fun will send the ACK ok = tests_util:wait(Ref, [{client1, ack}, {client1, dialog_confirmed}, diff --git a/test/ipv6_test.erl b/test/ipv6_test.erl index 16f8132d..be73183c 100644 --- a/test/ipv6_test.erl +++ b/test/ipv6_test.erl @@ -165,8 +165,8 @@ invite() -> RUri = "sip:[::1]:5071", Ref = make_ref(), Hds = {headers, [ - {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, self()}))}, - {"Nk-Op", "ok"} + {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, self()}))}, + {"x-nk-op", "ok"} ]}, {ok, 200, [{dialog_id, DialogId1}]} = nksip_uac:invite(C1, RUri, [Hds]), ok = nksip_uac:ack(C1, DialogId1, []), @@ -195,8 +195,8 @@ proxy() -> S1Uri = "sip:[::1]", Ref = make_ref(), Hds = {headers, [ - {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, self()}))}, - {"Nk-Op", "ok"} + {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, self()}))}, + {"x-nk-op", "ok"} ]}, {ok, 200, []} = nksip_uac:register(C1, S1Uri, [unregister_all]), @@ -211,8 +211,8 @@ proxy() -> %% and routes the request (stateless, no record_route) to Server2 %% Server2 routes to C2 (stateful, record_route) Route = {route, ""}, - {ok, 200, [{dialog_id, DialogId1}, {<<"Nk-Id">>, [<<"client2,server2,server1">>]}]} = - nksip_uac:invite(C1, "sip:client2@nksip", [Route, Hds, {fields, [<<"Nk-Id">>]}, + {ok, 200, [{dialog_id, DialogId1}, {<<"x-nk-id">>, [<<"client2,server2,server1">>]}]} = + nksip_uac:invite(C1, "sip:client2@nksip", [Route, Hds, {fields, [<<"x-nk-id">>]}, {supported, ""}]), % Without outbound, the Record-Route has the NkQ format, and it is converted % to NkS when back, with transport tcp @@ -238,7 +238,7 @@ bridge_4_6() -> %% Server1 and Server2 listens on both C1 = {ipv6, client1}, C3 = {ipv6, client3}, - Hds = {headers, [{"Nk-Op", "ok"}]}, + Hds = {headers, [{"x-nk-op", "ok"}]}, {ok, 200, []} = nksip_uac:register(C1, "sip:[::1]", [unregister_all]), {ok, 200, []} = nksip_uac:register(C3, "sip:127.0.0.1", [unregister_all]), @@ -252,13 +252,13 @@ bridge_4_6() -> %% and routes the request (stateless, no record_route, IPv6) to Server2 %% Server2 routes to C3 (stateful, record_route, IPv4) Route1 = {route, ""}, - Fields1 = {fields, [<<"Nk-Id">>, parsed_contacts]}, + Fields1 = {fields, [<<"x-nk-id">>, parsed_contacts]}, {ok, 200, Values1} = nksip_uac:invite(C1, "sip:client3@nksip", [Route1, Hds, Fields1, {supported, ""}]), %% C3 has generated a IPv4 Contact [ {dialog_id, DialogId1}, - {<<"Nk-Id">>, [<<"client3,server2,server1">>]}, + {<<"x-nk-id">>, [<<"client3,server2,server1">>]}, {parsed_contacts, [#uri{domain = <<"127.0.0.1">>}]} ] = Values1, diff --git a/test/outbound_test.erl b/test/outbound_test.erl index 98811ab5..e9f43356 100644 --- a/test/outbound_test.erl +++ b/test/outbound_test.erl @@ -112,7 +112,7 @@ basic() -> Ref = make_ref(), Self = self(), CB = {callback, fun ({req, R}) -> Self ! {Ref, R}; (_) -> ok end}, - % RepHd = {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}, + % RepHd = {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}, {ok, 603, []} = nksip_uac:invite(C2, "sip:127.0.0.1:5103", [make_contact, CB, get_request]), @@ -148,9 +148,9 @@ flow() -> % but, as both parties support otbound, and the connection is direct, % registrar adds a path with the flow - {ok, 200, [{<<"Require">>, []}, {parsed_contacts, [PContact]}, {local, Local}]} = + {ok, 200, [{<<"require">>, []}, {parsed_contacts, [PContact]}, {local, Local}]} = nksip_uac:register(C1, "", - [make_contact, {fields, [<<"Require">>, parsed_contacts, local]}]), + [make_contact, {fields, [<<"require">>, parsed_contacts, local]}]), #uri{ user = <<"ua1">>, domain = <<"127.0.0.1">>, port = 5101, @@ -180,7 +180,7 @@ flow() -> [#uri{ user = <<"ua1">>, domain = <<"127.0.0.1">>, port = 5101, opts = [{<<"transport">>, <<"tcp">>}], - headers = [{<<"Route">>, QRoute1}], + headers = [{<<"route">>, QRoute1}], ext_opts = [] }=Contact1] = nksip_registrar:find(R1, sip, <<"ua1">>, <<"nksip">>), @@ -205,7 +205,7 @@ flow() -> QRoute2 = http_uri:encode(binary_to_list(nksip_unparse:uri(Path1#uri{user = <<>>}))), {ok, 200, []} = - nksip_uac:options(C1, Contact1#uri{headers=[{<<"Route">>, QRoute2}]}, []), + nksip_uac:options(C1, Contact1#uri{headers=[{<<"route">>, QRoute2}]}, []), [ {#transport{local_port=5101, remote_port=RemotePort}, _}, @@ -378,7 +378,7 @@ proxy() -> {fields, [parsed_require]}]), Contact1 = nksip_registrar:find(R1, sip, <<"ua1">>, <<"nksip">>), - [#uri{headers=[{<<"Route">>, QRoute1}]}] = Contact1, + [#uri{headers=[{<<"route">>, QRoute1}]}] = Contact1, [Path1, Path2] = nksip_parse:uris(http_uri:decode(binary_to_list(QRoute1))), #uri{user = <<"NkQ", _/binary>>, port = 5080} = Path1, @@ -397,7 +397,7 @@ proxy() -> % Now, if we send a request to this contact, it will go to % P3, to P1, and P1 will use the indicated flow to go to UA1 {ok, 200, [{_, [<<"ua1,p1,p3">>]}]} = - nksip_uac:options(C2, Contact1, [{fields, [<<"Nk-Id">>]}]), + nksip_uac:options(C2, Contact1, [{fields, [<<"x-nk-id">>]}]), % If we stop the flow, P1 will return Flow Failed nksip_connection:stop(Pid1, normal), @@ -421,7 +421,7 @@ proxy() -> {fields, [parsed_require]}]), Contact2 = nksip_registrar:find(R1, sip, <<"ua1">>, <<"nksip">>), - [#uri{headers=[{<<"Route">>, QRoute2}]}] = Contact2, + [#uri{headers=[{<<"route">>, QRoute2}]}] = Contact2, [Path3] = nksip_parse:uris(http_uri:decode(binary_to_list(QRoute2))), #uri{ @@ -432,7 +432,7 @@ proxy() -> {ok, 200, [{dialog_id, DialogId}]} = nksip_uac:invite(C2, Contact2, - [auto_2xx_ack, {headers, [{"Nk-Op", "ok"}]}]), + [auto_2xx_ack, {headers, [{"x-nk-op", "ok"}]}]), [ #uri{ diff --git a/test/path_server.erl b/test/path_server.erl index c372d976..c608658c 100644 --- a/test/path_server.erl +++ b/test/path_server.erl @@ -51,7 +51,7 @@ init(Id) -> % It domain is 'nksip', it sends the request to P2, inserting Path and Nk-Id headers % If not, simply proxies the request adding a Nk-Id header route(_, _, _, Domain, _, #state{id={_, p1}}=State) -> - Base = [{headers, [{"Nk-Id", "p1"}]}], + Base = [{headers, [{"x-nk-id", "p1"}]}], case Domain of <<"nksip">> -> Opts = [{route, ""}, @@ -65,7 +65,7 @@ route(_, _, _, Domain, _, #state{id={_, p1}}=State) -> % For 'nksip' domain, sends the request to P3, inserting Nk-Id header % For other, simply proxies and adds header route(_, _, _, Domain, _, #state{id={_, p2}}=State) -> - Base = [{headers, [{"Nk-Id", "p2"}]}], + Base = [{headers, [{"x-nk-id", "p2"}]}], case Domain of <<"nksip">> -> Opts = [{route, ""}|Base], @@ -79,7 +79,7 @@ route(_, _, _, Domain, _, #state{id={_, p2}}=State) -> % For 'nksip', it sends everything to the registrar, inserting Path header % For other proxies the request route(_, _, _, Domain, _, #state{id={_, p3}}=State) -> - Base = [{headers, [{"Nk-Id", "p3"}]}], + Base = [{headers, [{"x-nk-id", "p3"}]}], case Domain of <<"nksip">> -> Opts = [{route, ""}, make_path, record_route|Base], @@ -93,7 +93,7 @@ route(_, _, _, Domain, _, #state{id={_, p3}}=State) -> % For 'nksip', it sends everything to the registrar, inserting Path header % For other proxies the request route(_, _, _, _, _, #state{id={_, p4}}=State) -> - Base = [{headers, [{"Nk-Id", "p4"}]}, make_path, record_route], + Base = [{headers, [{"x-nk-id", "p4"}]}, make_path, record_route], {reply, {proxy, ruri, Base}, State}; diff --git a/test/path_test.erl b/test/path_test.erl index e6f411bd..e51a2b75 100644 --- a/test/path_test.erl +++ b/test/path_test.erl @@ -94,20 +94,20 @@ basic() -> % We didn't send the Supported header, so first proxy % (P1, configured to include Path) sends a 421 (Extension Required) - {ok, 421, [{<<"Require">>, [<<"path">>]}]} = - nksip_uac:register(C1, "sip:nksip", [{fields, [<<"Require">>]}, {supported, ""}]), + {ok, 421, [{<<"require">>, [<<"path">>]}]} = + nksip_uac:register(C1, "sip:nksip", [{fields, [<<"require">>]}, {supported, ""}]), % If the request arrives at registrar, having a valid Path header and % no Supported: path, it returns a 420 (Bad Extension) - {ok, 420, [{<<"Unsupported">>, [<<"path">>]}]} = + {ok, 420, [{<<"unsupported">>, [<<"path">>]}]} = nksip_uac:register(C1, "", [{route, ""}, - {fields, [<<"Unsupported">>]}, {supported, ""}]), + {fields, [<<"unsupported">>]}, {supported, ""}]), - {ok, 200, [{<<"Path">>, [P1, P2]}]} = + {ok, 200, [{<<"path">>, [P1, P2]}]} = nksip_uac:register(C1, "sip:nksip", - [make_supported, make_contact, {fields, [<<"Path">>]}]), + [make_supported, make_contact, {fields, [<<"path">>]}]), [#reg_contact{ contact = #uri{scheme = sip,user = <<"ua1">>,domain = <<"127.0.0.1">>}, @@ -126,7 +126,7 @@ basic() -> % Now, if send a request to UA1, the registrar inserts the stored path % as routes, and requests pases throw P3, P1 and to UA1 {ok, 200, [{_, [<<"ua1,p1,p3">>]}]} = - nksip_uac:options(C2, "sip:ua1@nksip", [{fields, [<<"Nk-Id">>]}]), + nksip_uac:options(C2, "sip:ua1@nksip", [{fields, [<<"x-nk-id">>]}]), ok. diff --git a/test/prack_endpoint.erl b/test/prack_endpoint.erl index 8120a15d..9a9ed210 100644 --- a/test/prack_endpoint.erl +++ b/test/prack_endpoint.erl @@ -54,11 +54,11 @@ init([Id]) -> invite(ReqId, Meta, From, #state{id=Id, dialogs=Dialogs}=State) -> AppId = {prack, Id}, DialogId = nksip_lib:get_value(dialog_id, Meta), - Op = case nksip_request:header(AppId, ReqId, <<"Nk-Op">>) of + Op = case nksip_request:header(AppId, ReqId, <<"x-nk-op">>) of [Op0] -> Op0; _ -> <<"decline">> end, - case nksip_request:header(AppId, ReqId, <<"Nk-Reply">>) of + case nksip_request:header(AppId, ReqId, <<"x-nk-reply">>) of [RepBin] -> {Ref, Pid} = erlang:binary_to_term(base64:decode(RepBin)), State1 = State#state{dialogs=[{DialogId, Ref, Pid}|Dialogs]}; @@ -139,7 +139,7 @@ ack(ReqId, Meta, _From, #state{id=Id, dialogs=Dialogs}=State) -> DialogId = nksip_lib:get_value(dialog_id, Meta), case lists:keyfind(DialogId, 1, Dialogs) of false -> - case nksip_request:header(AppId, ReqId, <<"Nk-Reply">>) of + case nksip_request:header(AppId, ReqId, <<"x-nk-reply">>) of [RepBin] -> {Ref, Pid} = erlang:binary_to_term(base64:decode(RepBin)), Pid ! {Ref, {Id, ack}}; diff --git a/test/prack_test.erl b/test/prack_test.erl index 0576a46c..c9b80309 100644 --- a/test/prack_test.erl +++ b/test/prack_test.erl @@ -80,7 +80,7 @@ basic() -> CB = {callback, fun(Reply) -> Self ! {Ref, Reply} end}, % No make_100rel in call to invite, neither in app config - Hds1 = {headers, [{"Nk-Op", "prov-busy"}]}, + Hds1 = {headers, [{"x-nk-op", "prov-busy"}]}, Fields1 = {fields, [parsed_supported, parsed_require]}, {ok, 486, Values1} = nksip_uac:invite(C1, SipC2, [CB, get_request, Hds1, Fields1]), [ {parsed_supported, [<<"100rel">>]}, @@ -116,8 +116,8 @@ basic() -> % Ask for 100rel in UAS Hds2 = {headers, [ - {"Nk-Op", "rel-prov-busy"}, - {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}]}, + {"x-nk-op", "rel-prov-busy"}, + {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}]}, Fields2 = {fields, [parsed_supported, parsed_require, cseq_num, rseq_num]}, {ok, 486, Values2} = nksip_uac:invite(C1, SipC2, [CB, get_request, Hds2, Fields2, {require, "100rel"}]), @@ -179,8 +179,8 @@ pending() -> Ref = make_ref(), Self = self(), Hds = {headers, [ - {"Nk-Op", "pending"}, - {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}]}, + {"x-nk-op", "pending"}, + {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}]}, {ok, 486, _} = nksip_uac:invite(C1, SipC2, [Hds]), receive @@ -196,7 +196,7 @@ media() -> Ref = make_ref(), Self = self(), SDP = nksip_sdp:new("client1", [{"test", 1234, [{rtpmap, 0, "codec1"}]}]), - RepHd = {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}, + RepHd = {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}, % A session with media offer in INVITE, answer in reliable provisional % and final responses. @@ -204,7 +204,7 @@ media() -> % session are received. % We don't receive callbacks from client1, since it has not stored the reply in % its state - Hds1 = [{"Nk-Op", "rel-prov-answer"}, RepHd], + Hds1 = [{"x-nk-op", "rel-prov-answer"}, RepHd], {ok, 200, [{dialog_id, DialogId1}]} = nksip_uac:invite(C1, "sip:ok@127.0.0.1:5070", [{headers, Hds1}, {body, SDP}]), ok = nksip_uac:ack(C1, DialogId1, []), @@ -228,7 +228,7 @@ media() -> % A session with media offer in INVITE, answer in reliable provisional % and new offer in PRACK (answer in respone to PRACk) - Hds2 = [{"Nk-Op", "rel-prov-answer2"}, RepHd], + Hds2 = [{"x-nk-op", "rel-prov-answer2"}, RepHd], CB = {prack, fun(<<>>, #sipmsg{}) -> Self ! {Ref, prack_sdp_ok}, @@ -256,7 +256,7 @@ media() -> % A session with no media offer in INVITE, offer in reliable provisional % and answer in PRACK - Hds3 = [{"Nk-Op", "rel-prov-answer3"}, RepHd], + Hds3 = [{"x-nk-op", "rel-prov-answer3"}, RepHd], CB3 = {prack, fun(FunSDP, #sipmsg{}) -> FunLocalSDP = FunSDP#sdp{ diff --git a/test/proxy_test.erl b/test/proxy_test.erl index 7fc3be36..9f37f998 100644 --- a/test/proxy_test.erl +++ b/test/proxy_test.erl @@ -136,10 +136,10 @@ invalid(Test) -> % client@nksip is registered by C2, but it will fail because of Proxy-Require Opts3 = [ - {headers, [{"Proxy-Require", "a, b;c=1,d"}]}, - {fields, [call_id, <<"Unsupported">>]} + {headers, [{"proxy-require", "a, b;c=1,d"}]}, + {fields, [call_id, <<"unsupported">>]} ], - {ok, 420, [{call_id, CallId3}, {<<"Unsupported">>, [<<"a,b,d">>]}]} = + {ok, 420, [{call_id, CallId3}, {<<"unsupported">>, [<<"a,b,d">>]}]} = nksip_uac:options(C1, "sip:client2@nksip", Opts3), % The 420 response is always stateless @@ -179,33 +179,33 @@ opts(Test) -> {ok, 200, []} = nksip_uac:register(C1, "sip:127.0.0.1", [make_contact]), {ok, 200, []} = nksip_uac:register(C2, "sip:127.0.0.1", [make_contact]), - % % Server1 proxies the request to client2@nksip using ServerOpts1 options: - % % two "Nk" headers are added - % ServerOpts1 = [{headers, [{"Nk", "server"}, {"Nk", Test}]}], - % Body1 = base64:encode(term_to_binary(ServerOpts1)), - % Opts1 = [{headers, [{"Nk", "opts2"}]}, {body, Body1}, {fields, [<<"Nk">>]}], - % {ok, 200, Values1} = nksip_uac:options(C1, "sip:client2_op@nksip", Opts1), - % Res1Rep = list_to_binary(["server,",atom_to_list(Test),",opts2"]), - % [{<<"Nk">>, [Res1Rep]}] = Values1, - - % % Remove headers at server - % ServerOpts2 = [{headers, [{"Nk", "server"}]}, remove_headers], - % Body2 = base64:encode(term_to_binary(ServerOpts2)), - % Opts2 = [{headers, [{"Nk", "opts2"}]}, {body, Body2}, {fields, [<<"Nk">>]}], - % {ok, 200, Values2} = nksip_uac:options(C1, "sip:client2_op@nksip", Opts2), - % [{<<"Nk">>, [<<"server">>]}] = Values2, + % Server1 proxies the request to client2@nksip using ServerOpts1 options: + % two "x-nk" headers are added + ServerOpts1 = [{headers, [{"x-nk", "server"}, {"x-nk", Test}]}], + Body1 = base64:encode(term_to_binary(ServerOpts1)), + Opts1 = [{headers, [{"x-nk", "opts2"}]}, {body, Body1}, {fields, [<<"x-nk">>]}], + {ok, 200, Values1} = nksip_uac:options(C1, "sip:client2_op@nksip", Opts1), + Res1Rep = list_to_binary(["server,",atom_to_list(Test),",opts2"]), + [{<<"x-nk">>, [Res1Rep]}] = Values1, + + % Remove headers at server + ServerOpts2 = [{headers, [{"x-nk", "server"}]}, remove_headers], + Body2 = base64:encode(term_to_binary(ServerOpts2)), + Opts2 = [{headers, [{"x-nk", "opts2"}]}, {body, Body2}, {fields, [<<"x-nk">>]}], + {ok, 200, Values2} = nksip_uac:options(C1, "sip:client2_op@nksip", Opts2), + [{<<"x-nk">>, [<<"server">>]}] = Values2, - % % Add a route at server - % ServerOpts3 = [{headers, [{"Nk", "server2"}]}, - % {route, ", "}], - % Body3 = base64:encode(term_to_binary(ServerOpts3)), - % Opts3 = [{headers, [{"Nk", "opts2"}]}, {body, Body3}, - % {fields, [<<"Nk">>, <<"Nk-R">>]}], - % {ok, 200, Values3} = nksip_uac:options(C1, "sip:client2_op@nksip", Opts3), - % [ - % {<<"Nk">>, [<<"server2,opts2">>]}, - % {<<"Nk-R">>, [<<",">>]} - % ] = Values3, + % Add a route at server + ServerOpts3 = [{headers, [{"x-nk", "server2"}]}, + {route, ", "}], + Body3 = base64:encode(term_to_binary(ServerOpts3)), + Opts3 = [{headers, [{"x-nk", "opts2"}]}, {body, Body3}, + {fields, [<<"x-nk">>, <<"x-nk-r">>]}], + {ok, 200, Values3} = nksip_uac:options(C1, "sip:client2_op@nksip", Opts3), + [ + {<<"x-nk">>, [<<"server2,opts2">>]}, + {<<"x-nk-r">>, [<<",">>]} + ] = Values3, % Add a route from client ServerOpts4 = [], @@ -214,13 +214,13 @@ opts(Test) -> Opts4 = [{route, ["", Uri2#uri{opts=[lr], ext_opts=[]}, <<"sip:aaa">>]}, {body, Body4}, - {fields, [<<"Nk">>, <<"Nk-R">>]}], + {fields, [<<"x-nk">>, <<"x-nk-r">>]}], {ok, 200, Values4} = nksip_uac:options(C1, "sip:client2_op@nksip", Opts4), NkR4 = nksip_lib:bjoin([nksip_unparse:uri(Uri2#uri{opts=[lr], ext_opts=[]}), <<"">>]), [ - {<<"Nk">>, []}, - {<<"Nk-R">>, [NkR4]} + {<<"x-nk">>, []}, + {<<"x-nk-r">>, [NkR4]} ] = Values4, % Remove route from client at server @@ -228,11 +228,11 @@ opts(Test) -> Body5 = base64:encode(term_to_binary(ServerOpts5)), Opts5 = [{route, ["", Uri2#uri{opts=[lr]}, <<"sip:aaa">>]}, {body, Body5}, - {fields, [<<"Nk">>, <<"Nk-R">>]}], + {fields, [<<"x-nk">>, <<"x-nk-r">>]}], {ok, 200, Values5} = nksip_uac:options(C1, "sip:client2_op@nksip", Opts5), [ - {<<"Nk">>, []}, - {<<"Nk-R">>, []} + {<<"x-nk">>, []}, + {<<"x-nk-r">>, []} ] = Values5, {ok, 200, []} = nksip_uac:register(C1, "sip:127.0.0.1", [unregister_all]), @@ -248,10 +248,10 @@ transport(Test) -> {ok, 200, []} = nksip_uac:register(C1, "sip:127.0.0.1", [make_contact]), {ok, 200, []} = nksip_uac:register(C2, "sip:127.0.0.1", [make_contact]), - {ok, 200, [{<<"Nk-Id">>, [<<"client2,server1">>]}]} = - nksip_uac:options(C1, "sip:client2@nksip", [{fields, [<<"Nk-Id">>]}]), - {ok, 200, [{<<"Nk-Id">>, [<<"client1,server1">>]}]} = - nksip_uac:options(C2, "sip:client1@nksip", [{fields, [<<"Nk-Id">>]}]), + {ok, 200, [{<<"x-nk-id">>, [<<"client2,server1">>]}]} = + nksip_uac:options(C1, "sip:client2@nksip", [{fields, [<<"x-nk-id">>]}]), + {ok, 200, [{<<"x-nk-id">>, [<<"client1,server1">>]}]} = + nksip_uac:options(C2, "sip:client1@nksip", [{fields, [<<"x-nk-id">>]}]), {ok, 200, []} = nksip_uac:register(C1, "sip:127.0.0.1", [unregister_all]), {ok, 200, []} = nksip_uac:register(C2, "sip:127.0.0.1", [unregister_all]), @@ -279,16 +279,16 @@ transport(Test) -> % This request is sent using UDP, proxied using TCP {ok, 200, Values4} = nksip_uac:options(C1, "sip:client2@nksip", - [{fields, [remote, <<"Nk-Id">>]}]), + [{fields, [remote, <<"x-nk-id">>]}]), [ {remote, {udp, {127,0,0,1}, 5060, <<>>}}, - {<<"Nk-Id">>, [<<"client2,server1">>]} + {<<"x-nk-id">>, [<<"client2,server1">>]} ] = Values4, nksip_uac:options(C2, "sip:client1@nksip", [{route, ""}, async, CB, get_request, - {fields, [local, remote, <<"Nk-Id">>]}]), + {fields, [local, remote, <<"x-nk-id">>]}]), receive {Ref, {req, ReqId5}} -> % Should reuse transport @@ -301,7 +301,7 @@ transport(Test) -> [ {local, {tcp, {127,0,0,1}, LPort, <<>>}}, {remote, {tcp, {127,0,0,1}, 5060, <<>>}}, - {<<"Nk-Id">>, [<<"client1,server1">>]} + {<<"x-nk-id">>, [<<"client1,server1">>]} ] = Values5 after 1000 -> error(transport) @@ -322,47 +322,47 @@ invite(Test) -> Ref = make_ref(), Self = self(), - RepHd = {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}, + RepHd = {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}, RespFun = fun({ok, Code, _}) -> Self ! {Ref, Code} end, % Provisional 180 and Busy {ok, 486, []} = nksip_uac:invite(C1, "sip:client2@nksip", - [{headers, [{"Nk-Op", busy}, {"Nk-Prov", true}]}, + [{headers, [{"x-nk-op", busy}, {"x-nk-prov", true}]}, {callback, RespFun}]), ok = tests_util:wait(Ref, [180]), % Provisional 180 and 200 {ok, 200, [{dialog_id, DialogId1}]} = nksip_uac:invite(C1, "sip:client2@nksip", - [{headers, [{"Nk-Op", ok}, {"Nk-Prov", true}, - {"Nk-Sleep", 100}, RepHd]}, + [{headers, [{"x-nk-op", ok}, {"x-nk-prov", true}, + {"x-nk-sleep", 100}, RepHd]}, {callback, RespFun}]), ok = nksip_uac:ack(C1, DialogId1, []), ok = tests_util:wait(Ref, [180, {client2, ack}]), % Several in-dialog requests - {ok, 200, [{<<"Nk-Id">>, [<<"client2">>]}]} = - nksip_uac:options(C1, DialogId1, [{fields, [<<"Nk-Id">>]}]), + {ok, 200, [{<<"x-nk-id">>, [<<"client2">>]}]} = + nksip_uac:options(C1, DialogId1, [{fields, [<<"x-nk-id">>]}]), DialogId2 = nksip_dialog:field(C1, DialogId1, remote_id), - {ok, 200, [{<<"Nk-Id">>, [<<"client1">>]}]} = - nksip_uac:options(C2, DialogId2, [{fields, [<<"Nk-Id">>]}]), - {ok, 200, [{dialog_id, DialogId1}, {<<"Nk-Id">>, [<<"client2">>]}]} = - nksip_uac:invite(C1, DialogId1, [{headers, [{"Nk-Op", ok}]}, - {fields, [<<"Nk-Id">>]}]), + {ok, 200, [{<<"x-nk-id">>, [<<"client1">>]}]} = + nksip_uac:options(C2, DialogId2, [{fields, [<<"x-nk-id">>]}]), + {ok, 200, [{dialog_id, DialogId1}, {<<"x-nk-id">>, [<<"client2">>]}]} = + nksip_uac:invite(C1, DialogId1, [{headers, [{"x-nk-op", ok}]}, + {fields, [<<"x-nk-id">>]}]), ok = nksip_uac:ack(C1, DialogId1, []), ok = tests_util:wait(Ref, [{client2, ack}]), - {ok, 200, [{dialog_id, DialogId2}, {<<"Nk-Id">>, [<<"client1">>]}]} = - nksip_uac:invite(C2, DialogId2, [{headers, [{"Nk-Op", ok}, RepHd]}, - {fields, [<<"Nk-Id">>]}]), + {ok, 200, [{dialog_id, DialogId2}, {<<"x-nk-id">>, [<<"client1">>]}]} = + nksip_uac:invite(C2, DialogId2, [{headers, [{"x-nk-op", ok}, RepHd]}, + {fields, [<<"x-nk-id">>]}]), ok = nksip_uac:ack(C2, DialogId2, []), ok = tests_util:wait(Ref, [{client1, ack}]), {ok, 200, []} = nksip_uac:bye(C1, DialogId1, []), % Cancelled request {async, ReqId7} = nksip_uac:invite(C1, "sip:client2@nksip", - [{headers, [{"Nk-Op", ok}, - {"Nk-Sleep", 5000}, RepHd]}, + [{headers, [{"x-nk-op", ok}, + {"x-nk-sleep", 5000}, RepHd]}, async, {callback, RespFun}]), ok = nksip_uac:cancel(C1, ReqId7), ok = tests_util:wait(Ref, [487, {client2, bye}]), @@ -373,7 +373,7 @@ servers(Test) -> C2 = {Test, client2}, Ref = make_ref(), Self = self(), - RepHd = {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}, + RepHd = {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}, Opts2 = [{route, ""}, {from, "sips:client2@nksip2"}], {ok, 200, []} = nksip_uac:register(C1, "sip:127.0.0.1", [unregister_all]), @@ -386,7 +386,7 @@ servers(Test) -> % As the RURI is sips, it will be sent using sips, even if our Route is sip % server1 detects nksip2 is a domain for server2, and routes to there % client2 answers - Fs1 = {fields, [remote, <<"Nk-Id">>]}, + Fs1 = {fields, [remote, <<"x-nk-id">>]}, {ok, 200, Values1} = nksip_uac:options(C1, "sips:client2@nksip2", [Fs1]), [ {remote, {tls, {127,0,0,1}, 5061, <<>>}}, @@ -402,13 +402,13 @@ servers(Test) -> % Test a dialog through 2 proxies without Record-Route - Fs3 = {fields, [<<"Contact">>, <<"Nk-Id">>]}, + Fs3 = {fields, [<<"contact">>, <<"x-nk-id">>]}, {ok, 200, Values3} = nksip_uac:invite(C1, "sips:client2@nksip2", - [Fs3, {headers, [{"Nk-Op", ok}, RepHd]}]), + [Fs3, {headers, [{"x-nk-op", ok}, RepHd]}]), [ {dialog_id, DialogIdA1}, - {<<"Contact">>, [C2Contact]}, - {<<"Nk-Id">>, [<<"client2,server2,server1">>]} + {<<"contact">>, [C2Contact]}, + {<<"x-nk-id">>, [<<"client2,server2,server1">>]} ] = Values3, [#uri{port=C2Port}] = nksip_parse:uris(C2Contact), @@ -418,31 +418,31 @@ servers(Test) -> ok = tests_util:wait(Ref, [{client2, ack}]), % OPTIONS is also sent directly - Fs4 = {fields, [remote, <<"Nk-Id">>]}, + Fs4 = {fields, [remote, <<"x-nk-id">>]}, {ok, 200, Values4} = nksip_uac:options(C1, DialogIdA1, [Fs4]), [ {remote, {tls, {127,0,0,1}, _, <<>>}}, - {<<"Nk-Id">>, [<<"client2">>]} + {<<"x-nk-id">>, [<<"client2">>]} ] = Values4, DialogIdA2 = nksip_dialog:field(C1, DialogIdA1, remote_id), {ok, 200, Values5} = nksip_uac:options(C2, DialogIdA2, [Fs4]), [ {remote, {tls, {127,0,0,1}, 5071, <<>>}}, - {<<"Nk-Id">>, [<<"client1">>]} + {<<"x-nk-id">>, [<<"client1">>]} ] = Values5, {ok, 200, []} = nksip_uac:bye(C1, DialogIdA1, []), ok = tests_util:wait(Ref, [{client2, bye}]), % Test a dialog through 2 proxies with Record-Route - Hds6 = {headers, [{"Nk-Op", ok}, {"Nk-Rr", true}, RepHd]}, - Fs6 = {fields, [<<"Record-Route">>, <<"Nk-Id">>]}, + Hds6 = {headers, [{"x-nk-op", ok}, {"x-nk-rr", true}, RepHd]}, + Fs6 = {fields, [<<"record-route">>, <<"x-nk-id">>]}, {ok, 200, Values6} = nksip_uac:invite(C1, "sips:client2@nksip2", [Hds6, Fs6]), [ {dialog_id, DialogIdB1}, - {<<"Record-Route">>, [RR1, RR2]}, - {<<"Nk-Id">>, [<<"client2,server2,server1">>]} + {<<"record-route">>, [RR1, RR2]}, + {<<"x-nk-id">>, [<<"client2,server2,server1">>]} ] = Values6, [#uri{port=5081, opts=[{<<"transport">>, <<"tls">>}, <<"lr">>]}] = nksip_parse:uris(RR1), @@ -453,7 +453,7 @@ servers(Test) -> {ok, 200, Values7} = nksip_uac:options(C1, DialogIdB1, [Fs4]), [ {remote, {tls, _, 5061, <<>>}}, - {<<"Nk-Id">>, [<<"client2,server2,server1">>]} + {<<"x-nk-id">>, [<<"client2,server2,server1">>]} ] = Values7, {req, AckReq} = nksip_uac:ack(C1, DialogIdB1, [get_request]), @@ -463,14 +463,14 @@ servers(Test) -> opts=[{<<"transport">>,<<"tls">>},<<"lr">>]}, #uri{scheme=sip, domain = <<"localhost">>, port=5081, opts=[{<<"transport">>,<<"tls">>},<<"lr">>]} - ] = nksip_sipmsg:header(AckReq, <<"Route">>, uris), + ] = nksip_sipmsg:header(AckReq, <<"route">>, uris), ok = tests_util:wait(Ref, [{client2, ack}]), DialogIdB2 = nksip_dialog:field(C1, DialogIdB1, remote_id), - Fs8 = {fields, [<<"Nk-Id">>]}, + Fs8 = {fields, [<<"x-nk-id">>]}, {ok, 200, Values8} = nksip_uac:options(C2, DialogIdB2, [Fs8]), - [{<<"Nk-Id">>, [<<"client1,server1,server2">>]}] = Values8, - {ok, 200, []} = nksip_uac:bye(C2, DialogIdB2, [{headers, [{"Nk-Rr", true}]}]), + [{<<"x-nk-id">>, [<<"client1,server1,server2">>]}] = Values8, + {ok, 200, []} = nksip_uac:bye(C2, DialogIdB2, [{headers, [{"x-nk-rr", true}]}]), ok. @@ -480,7 +480,7 @@ dialog() -> S1 = {stateful, server1}, Ref = make_ref(), Self = self(), - RepHd = {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}, + RepHd = {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}, {ok, 200, []} = nksip_uac:register(C1, "sip:127.0.0.1", [unregister_all]), {ok, 200, []} = nksip_uac:register(C2, "sip:127.0.0.1", [unregister_all]), @@ -489,7 +489,7 @@ dialog() -> SDP = nksip_sdp:new("client1", [{"test", 1234, [{rtpmap, 0, "codec1"}]}]), {ok, 200, Values1} = nksip_uac:invite(C1, "sip:client2@nksip", - [{headers, [{"Nk-Op", answer}, {"Nk-Rr", true}, RepHd]}, + [{headers, [{"x-nk-op", answer}, {"x-nk-rr", true}, RepHd]}, {body, SDP}]), [{dialog_id, DialogId1}] = Values1, ok = nksip_uac:ack(C1, DialogId1, []), @@ -555,7 +555,7 @@ dialog() -> parsed_local_target, parsed_remote_target, invite_local_sdp, invite_remote_sdp, parsed_route_set]), - {ok, 200, []} = nksip_uac:bye(C2, DialogId2, [{headers, [{"Nk-Rr", true}]}]), + {ok, 200, []} = nksip_uac:bye(C2, DialogId2, [{headers, [{"x-nk-rr", true}]}]), error = nksip_dialog:field(C1, DialogId1, status), error = nksip_dialog:field(C2, DialogId2, status), error = nksip_dialog:field(S1, DialogId1, status), diff --git a/test/register_test.erl b/test/register_test.erl index 0c6585f5..f4ea3d3e 100644 --- a/test/register_test.erl +++ b/test/register_test.erl @@ -85,8 +85,8 @@ register1() -> {ok, 405, []} = nksip_uac:register(Client2, "sip:127.0.0.1:5070", []), {ok, 200, Values1} = nksip_uac:register(Client1, "sip:127.0.0.1", - [unregister_all, {fields, [<<"Contact">>]}]), - [{<<"Contact">>, []}] = Values1, + [unregister_all, {fields, [<<"contact">>]}]), + [{<<"contact">>, []}] = Values1, [] = nksip_registrar:find(Server1, sip, <<"client1">>, <<"nksip">>), Ref = make_ref(), @@ -94,13 +94,13 @@ register1() -> RespFun = fun(Reply) -> Self ! {Ref, Reply} end, {async, _} = nksip_uac:register(Client1, "sip:127.0.0.1", [async, {callback, RespFun}, make_contact, get_request, - {fields, [<<"Contact">>]}, {supported, ""}]), + {fields, [<<"contact">>]}, {supported, ""}]), [CallId, CSeq] = receive {Ref, {req, Req2}} -> nksip_sipmsg:fields(Req2, [call_id, cseq_num]) after 2000 -> error(register1) end, Contact2 = receive - {Ref, {ok, 200, [{<<"Contact">>, [C2]}]}} -> C2 + {Ref, {ok, 200, [{<<"contact">>, [C2]}]}} -> C2 after 2000 -> error(register1) end, @@ -134,11 +134,11 @@ register1() -> {ok, 400, []} = nksip_uac:register(Client1, "sip:127.0.0.1", [{call_id, CallId}, {cseq, CSeq+1}, unregister_all]), - Opts3 = [{expires, Min-1}, make_contact, {fields, [<<"Min-Expires">>]}], + Opts3 = [{expires, Min-1}, make_contact, {fields, [<<"min-expires">>]}], {ok, 423, Values4} = nksip_uac:register(Client1, "sip:127.0.0.1", Opts3), [{_, [MinB]}] = Values4, - Opts4 = [{expires, Max+1}, make_contact, {fields, [<<"Contact">>]}], + Opts4 = [{expires, Max+1}, make_contact, {fields, [<<"contact">>]}], {ok, 200, Values5} = nksip_uac:register(Client1, "sip:127.0.0.1", Opts4), [{_, [Contact5]}] = Values5, Contact5 = MakeContact(MaxB), @@ -146,7 +146,7 @@ register1() -> ext_opts=[{<<"+sip.instance">>, _}, {<<"expires">>, MaxB}]}] = nksip_registrar:find(Server1, sip, <<"client1">>, <<"nksip">>), - Opts5 = [{expires, Min}, make_contact, {fields, [<<"Contact">>]}], + Opts5 = [{expires, Min}, make_contact, {fields, [<<"contact">>]}], ExpB = nksip_lib:to_binary(Min), {ok, 200, Values6} = nksip_uac:register(Client1, "sip:127.0.0.1", Opts5), [{_, [Contact6]}] = Values6, @@ -201,14 +201,14 @@ register2() -> Server1 = {basic, server1}, {ok, 200, Values1} = nksip_uac:register(Client1, "sip:127.0.0.1", - [unregister_all, {fields, [<<"Contact">>]}]), - [{<<"Contact">>, []}] = Values1, + [unregister_all, {fields, [<<"contact">>]}]), + [{<<"contact">>, []}] = Values1, [] = nksip_registrar:find(Server1, sip, <<"client1">>, <<"nksip">>), {ok, 200, Values2} = nksip_uac:register(Client1, "sip:127.0.0.1", [FromS, unregister_all, - {fields, [<<"Contact">>]}]), - [{<<"Contact">>, []}] = Values2, + {fields, [<<"contact">>]}]), + [{<<"contact">>, []}] = Values2, [] = nksip_registrar:find(Server1, sips, <<"client1">>, <<"nksip">>), {ok, 200, []} = nksip_uac:register(Client1, "sip:127.0.0.1", Opts1), @@ -222,9 +222,9 @@ register2() -> {ok, 200, Values3} = nksip_uac:register(Client1, "sips:127.0.0.1", [{contact, <<"">>}, - {fields, [<<"Contact">>]} + {fields, [<<"contact">>]} | Opts2--[make_contact]]), - [{<<"Contact">>, Contact3}] = Values3, + [{<<"contact">>, Contact3}] = Values3, Contact3Uris = nksip_parse:uris(Contact3), {ok, 200, Values4} = nksip_uac:register(Client1, "sip:127.0.0.1", diff --git a/test/sipapp_endpoint.erl b/test/sipapp_endpoint.erl index bdeb8651..2a74e93c 100644 --- a/test/sipapp_endpoint.erl +++ b/test/sipapp_endpoint.erl @@ -112,18 +112,18 @@ route(_ReqId, _Scheme, _User, _Domain, _From, SD) -> {reply, process, SD}. -% For OPTIONS requests, we copy in the response "Nk" headers and "Nk-Id" headers -% adding our own id, and "Nk-R" header with the received routes +% For OPTIONS requests, we copy in the response "X-Nk" headers and "X-Nk-Id" headers +% adding our own id, and "X-Nk-R" header with the received routes options(ReqId, _Meta, _From, #state{id={_, Id}=AppId}=State) -> - Values = nksip_request:header(AppId, ReqId, <<"Nk">>), - Ids = nksip_request:header(AppId, ReqId, <<"Nk-Id">>), - Routes = nksip_request:header(AppId, ReqId, <<"Route">>), + Values = nksip_request:header(AppId, ReqId, <<"x-nk">>), + Ids = nksip_request:header(AppId, ReqId, <<"x-nk-id">>), + Routes = nksip_request:header(AppId, ReqId, <<"route">>), Hds = [ - case Values of [] -> []; _ -> {<<"Nk">>, nksip_lib:bjoin(Values)} end, - case Routes of [] -> []; _ -> {<<"Nk-R">>, nksip_lib:bjoin(Routes)} end, - {<<"Nk-Id">>, nksip_lib:bjoin([Id|Ids])} + case Values of [] -> []; _ -> {<<"x-nk">>, nksip_lib:bjoin(Values)} end, + case Routes of [] -> []; _ -> {<<"x-nk-r">>, nksip_lib:bjoin(Routes)} end, + {<<"x-nk-id">>, nksip_lib:bjoin([Id|Ids])} ], - case nksip_request:header(AppId, ReqId, <<"Nk-Sleep">>) of + case nksip_request:header(AppId, ReqId, <<"x-nk-sleep">>) of [Sleep0] -> nksip_request:reply(AppId, ReqId, 101), timer:sleep(nksip_lib:to_integer(Sleep0)); @@ -140,7 +140,7 @@ options(_ReqId, _Meta, _From, State) -> % INVITE for auth tests invite(ReqId, Meta, _From, #state{id={auth, _}=AppId, dialogs=Dialogs}=State) -> DialogId = nksip_lib:get_value(dialog_id, Meta), - case nksip_request:header(AppId, ReqId, <<"Nk-Reply">>) of + case nksip_request:header(AppId, ReqId, <<"x-nk-reply">>) of [RepBin] -> {Ref, Pid} = erlang:binary_to_term(base64:decode(RepBin)), State1 = State#state{dialogs=[{DialogId, Ref, Pid}|Dialogs]}; @@ -154,9 +154,9 @@ invite(ReqId, Meta, _From, #state{id={auth, _}=AppId, dialogs=Dialogs}=State) -> % Gets operation from body invite(ReqId, Meta, From, #state{id={fork, Id}=AppId, dialogs=Dialogs}=State) -> DialogId = nksip_lib:get_value(dialog_id, Meta), - Ids = nksip_request:header(AppId, ReqId, <<"Nk-Id">>), - Hds = [{<<"Nk-Id">>, nksip_lib:bjoin([Id|Ids])}], - case nksip_request:header(AppId, ReqId, <<"Nk-Reply">>) of + Ids = nksip_request:header(AppId, ReqId, <<"x-nk-id">>), + Hds = [{<<"x-nk-id">>, nksip_lib:bjoin([Id|Ids])}], + case nksip_request:header(AppId, ReqId, <<"x-nk-reply">>) of [RepBin] -> {Ref, Pid} = erlang:binary_to_term(base64:decode(RepBin)), State1 = State#state{dialogs=[{DialogId, Ref, Pid}|Dialogs]}; @@ -199,7 +199,7 @@ invite(_ReqId, _Meta, _From, #state{id={event, _}}=State) -> % INVITE for timer test invite(ReqId, Meta, _From, #state{id={timer, _}=AppId, dialogs=Dialogs}=State) -> DialogId = nksip_lib:get_value(dialog_id, Meta), - State1 = case nksip_request:header(AppId, ReqId, <<"Nk-Reply">>) of + State1 = case nksip_request:header(AppId, ReqId, <<"x-nk-reply">>) of [RepBin] -> {Ref, Pid} = erlang:binary_to_term(base64:decode(RepBin)), State#state{dialogs=[{DialogId, Ref, Pid}|Dialogs]}; @@ -227,27 +227,27 @@ invite(ReqId, _Meta, From, #state{id={refer, _}=AppId}=State) -> % Copies all received Nk-Id headers adding our own Id invite(ReqId, Meta, From, #state{id={_, Id}=AppId, dialogs=Dialogs}=State) -> DialogId = nksip_lib:get_value(dialog_id, Meta), - Values = nksip_request:header(AppId, ReqId, <<"Nk">>), - Routes = nksip_request:header(AppId, ReqId, <<"Route">>), - Ids = nksip_request:header(AppId, ReqId, <<"Nk-Id">>), + Values = nksip_request:header(AppId, ReqId, <<"x-nk">>), + Routes = nksip_request:header(AppId, ReqId, <<"route">>), + Ids = nksip_request:header(AppId, ReqId, <<"x-nk-id">>), Hds = [ - case Values of [] -> []; _ -> {<<"Nk">>, nksip_lib:bjoin(Values)} end, - case Routes of [] -> []; _ -> {<<"Nk-R">>, nksip_lib:bjoin(Routes)} end, - {<<"Nk-Id">>, nksip_lib:bjoin([Id|Ids])} + case Values of [] -> []; _ -> {<<"x-nk">>, nksip_lib:bjoin(Values)} end, + case Routes of [] -> []; _ -> {<<"x-nk-r">>, nksip_lib:bjoin(Routes)} end, + {<<"x-nk-id">>, nksip_lib:bjoin([Id|Ids])} ], - Op = case nksip_request:header(AppId, ReqId, <<"Nk-Op">>) of + Op = case nksip_request:header(AppId, ReqId, <<"x-nk-op">>) of [Op0] -> Op0; _ -> <<"decline">> end, - Sleep = case nksip_request:header(AppId, ReqId, <<"Nk-Sleep">>) of + Sleep = case nksip_request:header(AppId, ReqId, <<"x-nk-sleep">>) of [Sleep0] -> nksip_lib:to_integer(Sleep0); _ -> 0 end, - Prov = case nksip_request:header(AppId, ReqId, <<"Nk-Prov">>) of + Prov = case nksip_request:header(AppId, ReqId, <<"x-nk-prov">>) of [<<"true">>] -> true; _ -> false end, - State1 = case nksip_request:header(AppId, ReqId, <<"Nk-Reply">>) of + State1 = case nksip_request:header(AppId, ReqId, <<"x-nk-reply">>) of [RepBin] -> {Ref, Pid} = erlang:binary_to_term(base64:decode(RepBin)), State#state{dialogs=[{DialogId, Ref, Pid}|Dialogs]}; @@ -293,7 +293,7 @@ ack(ReqId, Meta, _From, #state{id={_, Id}=AppId, dialogs=Dialogs}=State) -> DialogId = nksip_lib:get_value(dialog_id, Meta), case lists:keyfind(DialogId, 1, Dialogs) of false -> - case nksip_request:header(AppId, ReqId, <<"Nk-Reply">>) of + case nksip_request:header(AppId, ReqId, <<"x-nk-reply">>) of [RepBin] -> {Ref, Pid} = erlang:binary_to_term(base64:decode(RepBin)), Pid ! {Ref, {Id, ack}}; @@ -317,7 +317,7 @@ bye(_ReqId, Meta, _From, #state{id={_, Id}, dialogs=Dialogs}=State) -> info(ReqId, _Meta, _From, #state{id=AppId}=State) -> DialogId = nksip_request:dialog_id(AppId, ReqId), - {reply, {ok, [{"Nk-Method", "info"}, {"Nk-Dialog", DialogId}]}, State}. + {reply, {ok, [{"x-nk-method", "info"}, {"x-nk-dialog", DialogId}]}, State}. update(_ReqId, _Meta, _From, #state{id={timer, _}}=State) -> @@ -326,11 +326,11 @@ update(_ReqId, _Meta, _From, #state{id={timer, _}}=State) -> subscribe(ReqId, Meta, From, #state{id=AppId, dialogs=Dialogs}=State) -> DialogId = nksip_lib:get_value(dialog_id, Meta), - Op = case nksip_request:header(AppId, ReqId, <<"Nk-Op">>) of + Op = case nksip_request:header(AppId, ReqId, <<"x-nk-op">>) of [Op0] -> Op0; _ -> <<"ok">> end, - State1 = case nksip_request:header(AppId, ReqId, <<"Nk-Reply">>) of + State1 = case nksip_request:header(AppId, ReqId, <<"x-nk-reply">>) of [RepBin] -> {Ref, Pid} = erlang:binary_to_term(base64:decode(RepBin)), State#state{dialogs=[{DialogId, Ref, Pid}|Dialogs]}; @@ -370,7 +370,7 @@ notify(_ReqId, Meta, _From, #state{id={_, Id}, dialogs=Dialogs}=State) -> message(ReqId, _Meta, _From, #state{id=AppId}=State) -> % We could also use info in Meta - case nksip_request:header(AppId, ReqId, <<"Nk-Reply">>) of + case nksip_request:header(AppId, ReqId, <<"x-nk-reply">>) of [RepBin] -> {Ref, Pid} = erlang:binary_to_term(base64:decode(RepBin)), [ @@ -380,7 +380,7 @@ message(ReqId, _Meta, _From, #state{id=AppId}=State) -> {_, Body} ] = nksip_request:fields(AppId, ReqId, - [parsed_expires, <<"Date">>, content_type, body]), + [parsed_expires, <<"date">>, content_type, body]), Pid ! {Ref, {ok, Expires, Date, ContentType, Body}}, {reply, ok, State}; _ -> diff --git a/test/sipapp_inline_endpoint.erl b/test/sipapp_inline_endpoint.erl index ad82b7b3..70a3f773 100644 --- a/test/sipapp_inline_endpoint.erl +++ b/test/sipapp_inline_endpoint.erl @@ -45,7 +45,7 @@ init([]) -> invite(Req, _Meta, From) -> send_reply(Req, invite), - case nksip_sipmsg:header(Req, <<"Nk-Op">>) of + case nksip_sipmsg:header(Req, <<"x-nk-op">>) of [<<"wait">>] -> spawn( fun() -> @@ -82,9 +82,9 @@ options(Req, _Meta, From) -> send_reply(Req, options), spawn( fun() -> - [Server] = nksip_sipmsg:header(Req, <<"Nk-Id">>), + [Server] = nksip_sipmsg:header(Req, <<"x-nk-id">>), {inline, Id} = nksip_sipmsg:field(Req, app_id), - Reply = {ok, [{<<"Nk-Id">>, nksip_lib:bjoin([Server, Id])}]}, + Reply = {ok, [{<<"x-nk-id">>, nksip_lib:bjoin([Server, Id])}]}, nksip:reply(From, Reply) end), async. diff --git a/test/sipapp_inline_server.erl b/test/sipapp_inline_server.erl index c997b7f4..c95e5f76 100644 --- a/test/sipapp_inline_server.erl +++ b/test/sipapp_inline_server.erl @@ -48,7 +48,7 @@ get_user_pass(<<"client2">>, <<"nksip">>) -> <<"4321">>; get_user_pass(_, _) -> false. authorize(Req, Auth, From) -> - Reply = case nksip_sipmsg:header(Req, <<"Nksip-Auth">>) of + Reply = case nksip_sipmsg:header(Req, <<"x-nksip-auth">>) of [<<"true">>] -> case lists:member(dialog, Auth) orelse lists:member(register, Auth) of true -> @@ -73,7 +73,7 @@ route(Req, Scheme, User, Domain, _From) -> send_reply(Req, route), Opts = [ record_route, - {headers, [{"Nk-Id", Id}]} + {headers, [{"x-nk-id", Id}]} ], case lists:member(Domain, [<<"127.0.0.1">>, <<"nksip">>]) of true when User =:= <<>> -> diff --git a/test/sipapp_server.erl b/test/sipapp_server.erl index 3994f1e4..4b2334a9 100644 --- a/test/sipapp_server.erl +++ b/test/sipapp_server.erl @@ -106,11 +106,11 @@ route(ReqId, Scheme, User, Domain, _From, ], case lists:member(Domain, Domains) of true when User =:= <<>> -> - case nksip_request:header(AppId, ReqId, <<"Nksip-Op">>) of + case nksip_request:header(AppId, ReqId, <<"x-nk-op">>) of [<<"reply-request">>] -> Request = nksip_request:get_request(AppId, ReqId), Body = base64:encode(term_to_binary(Request)), - Hds = [{<<"Content-Type">>, <<"nksip/request">>}], + Hds = [{<<"content-type">>, <<"nksip/request">>}], {reply, {200, Hds, Body, [make_contact]}, State}; [<<"reply-stateless">>] -> {reply, {response, ok, [stateless]}, State}; @@ -142,8 +142,8 @@ route(ReqId, Scheme, User, Domain, _From, when Test=:=stateless; Test=:=stateful -> Opts = lists:flatten([ case Test of stateless -> stateless; _ -> [] end, - {headers, [{<<"Nk-Id">>, Id}]}, - case nksip_request:header(AppId, ReqId, <<"Nk-Rr">>) of + {headers, [{<<"x-nk-id">>, Id}]}, + case nksip_request:header(AppId, ReqId, <<"x-nk-rr">>) of [<<"true">>] -> record_route; _ -> [] end @@ -179,12 +179,12 @@ route(ReqId, Scheme, User, Domain, _From, route(ReqId, Scheme, User, Domain, _From, #state{id={fork, serverR}=AppId, domains=Domains}=State) -> Opts = lists:flatten([ - {headers, [{<<"Nk-Id">>, serverR}]}, - case nksip_request:header(AppId, ReqId, <<"Nk-Rr">>) of + {headers, [{<<"x-nk-id">>, serverR}]}, + case nksip_request:header(AppId, ReqId, <<"x-nk-rr">>) of [<<"true">>] -> record_route; _ -> [] end, - case nksip_request:header(AppId, ReqId, <<"Nk-Redirect">>) of + case nksip_request:header(AppId, ReqId, <<"x-nk-redirect">>) of [<<"true">>] -> follow_redirects; _ -> [] end @@ -211,7 +211,7 @@ route(_, _, _, Domain, _From, #state{id={fork, Id}, domains=Domains}=State) -> Opts = lists:flatten([ case Id of server1 -> stateless; _ -> [] end, record_route, - {headers, [{<<"Nk-Id">>, Id}]} + {headers, [{<<"x-nk-id">>, Id}]} ]), case lists:member(Domain, Domains) of true when Domain =:= <<"nksip">> -> diff --git a/test/timer_test.erl b/test/timer_test.erl index 57e6befa..4f1a69d2 100644 --- a/test/timer_test.erl +++ b/test/timer_test.erl @@ -96,7 +96,7 @@ basic() -> Ref = make_ref(), Self = self(), CB = {callback, fun ({req, R}) -> Self ! {Ref, R}; (_) -> ok end}, - RepHd = {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}, + RepHd = {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}, % C2 has a min_session_expires of 2 {error, invalid_session_expires} = @@ -108,9 +108,9 @@ basic() -> % C2 receives again the INVITE. Now it is valid. SDP1 = nksip_sdp:new(), - {ok, 200, [{dialog_id, Dialog1A}, {<<"Session-Expires">>,[<<"2;refresher=uas">>]}]} = + {ok, 200, [{dialog_id, Dialog1A}, {<<"session-expires">>,[<<"2;refresher=uas">>]}]} = nksip_uac:invite(C1, "sip:127.0.0.1:5072", - [{session_expires, 1}, {fields, [<<"Session-Expires">>]}, + [{session_expires, 1}, {fields, [<<"session-expires">>]}, CB, auto_2xx_ack, get_request, {body, SDP1}, {headers, [RepHd]}]), % Start events also at C1 @@ -119,8 +119,8 @@ basic() -> CallId1 = nksip_dialog:call_id(Dialog1A), CSeq1 = receive {Ref, #sipmsg{cseq=CSeq1_0, headers=Headers1, call_id=CallId1}} -> - <<"1">> = proplists:get_value(<<"Session-Expires">>, Headers1), - undefined = proplists:get_value(<<"Min-SE">>, Headers1), + <<"1">> = proplists:get_value(<<"session-expires">>, Headers1), + undefined = proplists:get_value(<<"min-sE">>, Headers1), CSeq1_0 after 1000 -> error(basic) @@ -128,8 +128,8 @@ basic() -> receive {Ref, #sipmsg{cseq=CSeq2, headers=Headers2, call_id=CallId1}} -> - <<"2">> = proplists:get_value(<<"Session-Expires">>, Headers2), - <<"2">> = proplists:get_value(<<"Min-SE">>, Headers2), + <<"2">> = proplists:get_value(<<"session-expires">>, Headers2), + <<"2">> = proplists:get_value(<<"min-se">>, Headers2), CSeq2 = CSeq1+1 after 1000 -> error(basic) @@ -181,8 +181,8 @@ basic() -> % received any 422 or refresh request with Min-SE header % The default Min-SE is 90 secs, so the refresh interval is updated to that - {ok, 200, [{<<"Session-Expires">>, [<<"90;refresher=uac">>]}]} = - nksip_uac:update(C2, Dialog1B, [{fields, [<<"Session-Expires">>]}]), + {ok, 200, [{<<"session-expires">>, [<<"90;refresher=uac">>]}]} = + nksip_uac:update(C2, Dialog1B, [{fields, [<<"session-expires">>]}]), 90 = nksip_dialog:field(C1, Dialog1A, invite_session_expires), undefined = nksip_dialog:field(C1, Dialog1A, invite_refresh), @@ -194,8 +194,8 @@ basic() -> % We force session_expires to a value C2 will not accept, so it will reply % 422 and a new request will be sent - {ok, 200, [{<<"Session-Expires">>,[<<"2;refresher=uas">>]}]} = - nksip_uac:update(C1, Dialog1A, [{session_expires, 1}, {fields, [<<"Session-Expires">>]}]), + {ok, 200, [{<<"session-expires">>,[<<"2;refresher=uas">>]}]} = + nksip_uac:update(C1, Dialog1A, [{session_expires, 1}, {fields, [<<"session-expires">>]}]), 2 = nksip_dialog:field(C1, Dialog1A, invite_session_expires), undefined = nksip_dialog:field(C1, Dialog1A, invite_refresh), @@ -207,13 +207,13 @@ basic() -> % NkSIP includes atomatically stored Session-Expires and Min-SE % It detects the remote party (C2) is currently refreshing a proposes refresher=uas - {ok, 200, [{<<"Session-Expires">>,[<<"2;refresher=uas">>]}]} = - nksip_uac:update(C1, Dialog1A, [get_request, CB, {fields, [<<"Session-Expires">>]}]), + {ok, 200, [{<<"session-expires">>,[<<"2;refresher=uas">>]}]} = + nksip_uac:update(C1, Dialog1A, [get_request, CB, {fields, [<<"session-expires">>]}]), receive {Ref, #sipmsg{headers=Headers3}} -> - <<"2;refresher=uas">> = proplists:get_value(<<"Session-Expires">>, Headers3), - <<"2">> = proplists:get_value(<<"Min-SE">>, Headers3) + <<"2;refresher=uas">> = proplists:get_value(<<"session-expires">>, Headers3), + <<"2">> = proplists:get_value(<<"min-se">>, Headers3) after 1000 -> error(basic) end, @@ -267,12 +267,12 @@ proxy() -> Ref = make_ref(), Self = self(), CB = {callback, fun ({req, R}) -> Self ! {Ref, R}; (_) -> ok end}, - RepHd = {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))}, + RepHd = {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))}, SDP1 = nksip_sdp:new(), - {ok, 200, [{dialog_id, Dialog1A}, {<<"Session-Expires">>,[<<"3;refresher=uas">>]}]} = + {ok, 200, [{dialog_id, Dialog1A}, {<<"session-expires">>,[<<"3;refresher=uas">>]}]} = nksip_uac:invite(C1, "sip:127.0.0.1:5072", - [{session_expires, 1}, {fields, [<<"Session-Expires">>]}, + [{session_expires, 1}, {fields, [<<"session-expires">>]}, CB, auto_2xx_ack, get_request, {body, SDP1}, {headers, [RepHd]}, {route, ""} ]), @@ -283,24 +283,24 @@ proxy() -> CallId1 = nksip_dialog:call_id(Dialog1A), receive {Ref, #sipmsg{headers=Headers1, call_id=CallId1}} -> - <<"1">> = proplists:get_value(<<"Session-Expires">>, Headers1), - undefined = proplists:get_value(<<"Min-SE">>, Headers1) + <<"1">> = proplists:get_value(<<"session-expires">>, Headers1), + undefined = proplists:get_value(<<"min-se">>, Headers1) after 1000 -> error(basic) end, receive {Ref, #sipmsg{headers=Headers2, call_id=CallId1}} -> - <<"2">> = proplists:get_value(<<"Session-Expires">>, Headers2), - <<"2">> = proplists:get_value(<<"Min-SE">>, Headers2) + <<"2">> = proplists:get_value(<<"session-expires">>, Headers2), + <<"2">> = proplists:get_value(<<"min-se">>, Headers2) after 1000 -> error(basic) end, receive {Ref, #sipmsg{headers=Headers3, call_id=CallId1}} -> - <<"3">> = proplists:get_value(<<"Session-Expires">>, Headers3), - <<"3">> = proplists:get_value(<<"Min-SE">>, Headers3) + <<"3">> = proplists:get_value(<<"session-expires">>, Headers3), + <<"3">> = proplists:get_value(<<"min-se">>, Headers3) after 1000 -> error(basic) end, @@ -334,9 +334,9 @@ proxy() -> % P1 received a Session-Timer of 1801. Since it has configured a % time of 1800, and it is > MinSE, it chages the value - {ok, 200, [{dialog_id, Dialog2}, {<<"Session-Expires">>,[<<"1800;refresher=uas">>]}]} = + {ok, 200, [{dialog_id, Dialog2}, {<<"session-expires">>,[<<"1800;refresher=uas">>]}]} = nksip_uac:invite(C1, "sip:127.0.0.1:5072", - [{session_expires, 1801}, {fields, [<<"Session-Expires">>]}, + [{session_expires, 1801}, {fields, [<<"session-expires">>]}, auto_2xx_ack, {body, SDP1}, {route, ""} ]), {ok, 200, []} = nksip_uac:bye(C1, Dialog2, []), @@ -345,11 +345,11 @@ proxy() -> % Now C1 does not support the timer extension. P1 adds a Session-Expires % header. C2 accepts the session proposal, but it doesn't add the % 'Require' header - {ok, 200, [{dialog_id, Dialog3A}, {<<"Session-Expires">>,[<<"1800;refresher=uas">>]}, + {ok, 200, [{dialog_id, Dialog3A}, {<<"session-expires">>,[<<"1800;refresher=uas">>]}, {parsed_require, []}]} = nksip_uac:invite(C1, "sip:127.0.0.1:5072", [{session_expires, 0}, {supported, "100rel,path"}, - {fields, [<<"Session-Expires">>, parsed_require]}, + {fields, [<<"session-expires">>, parsed_require]}, auto_2xx_ack, {body, SDP1}, {route, ""} ]), @@ -366,10 +366,10 @@ proxy() -> % Now C3 not support the timer extension. It does not return any % Session-Expires, but P2 remembers C1 supports the extension % and adds a response and require - {ok, 200, [{dialog_id, Dialog4A}, {<<"Session-Expires">>,[<<"1800;refresher=uac">>]}, + {ok, 200, [{dialog_id, Dialog4A}, {<<"session-expires">>,[<<"1800;refresher=uac">>]}, {parsed_require, [<<"timer">>]}]} = nksip_uac:invite(C1, "sip:127.0.0.1:5073", - [{fields, [<<"Session-Expires">>, parsed_require]}, + [{fields, [<<"session-expires">>, parsed_require]}, auto_2xx_ack, {body, SDP1}, {route, ""} ]), @@ -386,11 +386,11 @@ proxy() -> % None of UAC and UAS supports the extension % Router adds a Session-Expires header, but it is not honored - {ok, 200, [{dialog_id, Dialog5A}, {<<"Session-Expires">>,[]}, + {ok, 200, [{dialog_id, Dialog5A}, {<<"session-expires">>,[]}, {parsed_require, []}]} = nksip_uac:invite(C1, "sip:127.0.0.1:5073", [{session_expires, 0}, {supported, "100rel,path"}, - {fields, [<<"Session-Expires">>, parsed_require]}, + {fields, [<<"session-expires">>, parsed_require]}, auto_2xx_ack, {body, SDP1}, {route, ""} ]), diff --git a/test/uac_test.erl b/test/uac_test.erl index 05737e78..73d3169a 100644 --- a/test/uac_test.erl +++ b/test/uac_test.erl @@ -79,7 +79,7 @@ uac() -> Ref = make_ref(), Fun = fun(Reply) -> Self ! {Ref, Reply} end, CB = {callback, Fun}, - Hds = {headers, [{"Nk-Op", busy}, {"Nk-Prov", "true"}]}, + Hds = {headers, [{"x-nk-op", busy}, {"x-nk-prov", "true"}]}, nksip_trace:info("Next two infos about connection error to port 50600 are expected"), {error, service_unavailable} = @@ -174,14 +174,14 @@ info() -> C1 = {uac, client1}, C2 = {uac, client2}, SipC1 = "sip:127.0.0.1:5070", - Hds1 = {headers, [{<<"Nk-Op">>, <<"ok">>}]}, + Hds1 = {headers, [{<<"x-nk-op">>, <<"ok">>}]}, {ok, 200, [{dialog_id, DialogId2}]} = nksip_uac:invite(C2, SipC1, [Hds1]), ok = nksip_uac:ack(C2, DialogId2, []), - Fs = {fields, [<<"Nk-Method">>, <<"Nk-Dialog">>]}, + Fs = {fields, [<<"x-nk-method">>, <<"x-nk-dialog">>]}, DialogId1 = nksip_dialog:field(C2, DialogId2, remote_id), {ok, 200, Values1} = nksip_uac:info(C2, DialogId2, [Fs]), - [{<<"Nk-Method">>, [<<"info">>]}, {<<"Nk-Dialog">>, [DialogId1]}] = Values1, + [{<<"x-nk-method">>, [<<"info">>]}, {<<"x-nk-dialog">>, [DialogId1]}] = Values1, % Now we forcefully stop dialog at C1. At C2 is still valid, and can send the INFO ok = nksip_dialog:stop(C1, DialogId1), @@ -208,12 +208,12 @@ timeout() -> nksip_uac:invite(C2, "sip:127.0.0.1:9999", [{fields, [reason_phrase]}]), % REGISTER sends a provisional response, but the timeout is the same - Hds1 = {headers, [{<<"Nk-Sleep">>, 2000}]}, + Hds1 = {headers, [{<<"x-nk-sleep">>, 2000}]}, {ok, 408, [{reason_phrase, <<"Timer F Timeout">>}]} = nksip_uac:options(C2, SipC1, [Hds1, {fields, [reason_phrase]}]), % INVITE sends - Hds2 = {headers, [{"Nk-Op", busy}, {"Nk-Prov", "true"}, {"Nk-Sleep", 20000}]}, + Hds2 = {headers, [{"x-nk-op", busy}, {"x-nk-prov", "true"}, {"x-nk-sleep", 20000}]}, {ok, 408, [{reason_phrase, Reason}]} = nksip_uac:invite(C2, SipC1, [Hds2, {fields, [reason_phrase]}]), @@ -230,7 +230,7 @@ message() -> Ref = make_ref(), Self = self(), Hds = {headers, [ - {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))} + {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))} ]}, {ok, 200, []} = nksip_uac:message({uac,client2}, "sip:user@127.0.0.1:5070", [ Hds, {expires, 10}, {content_type, "text/plain"}, diff --git a/test/uas_test.erl b/test/uas_test.erl index 03974c1b..95c44c9f 100644 --- a/test/uas_test.erl +++ b/test/uas_test.erl @@ -76,7 +76,7 @@ uas() -> % Test loop detection Opts1 = [ - {headers, [{<<"Nksip-Op">>, <<"reply-stateful">>}]}, + {headers, [{<<"x-nk-op">>, <<"reply-stateful">>}]}, {fields, [call_id, from, cseq_num]} ], {ok, 200, Values1} = nksip_uac:options(C1, "sip:127.0.0.1", Opts1), @@ -88,7 +88,7 @@ uas() -> % Stateless proxies do not detect loops Opts3 = [ - {headers, [{<<"Nksip-Op">>, <<"reply-stateless">>}]}, + {headers, [{<<"x-nk-op">>, <<"reply-stateless">>}]}, {fields, [call_id, from, cseq_num]} ], {ok, 200, Values3} = nksip_uac:options(C1, "sip:127.0.0.1", Opts3), @@ -98,21 +98,21 @@ uas() -> {ok, 200, []} = nksip_uac:options(C1, "sip:127.0.0.1", ForceLoopOpts4), % Test bad extension endpoint and proxy - Opts5 = [{headers, [{"Require", "a,b;c,d"}]}, {fields, [all_headers]}], + Opts5 = [{headers, [{"require", "a,b;c,d"}]}, {fields, [all_headers]}], {ok, 420, [{all_headers, Hds5}]} = nksip_uac:options(C1, "sip:127.0.0.1", Opts5), % 'a' is supported because of app config - [<<"b,d">>] = proplists:get_all_values(<<"Unsupported">>, Hds5), + [<<"b,d">>] = proplists:get_all_values(<<"unsupported">>, Hds5), Opts6 = [ - {headers, [{"Proxy-Require", "a,b;c,d"}]}, + {headers, [{"proxy-require", "a,b;c,d"}]}, {route, ""}, {fields, [all_headers]} ], {ok, 420, [{all_headers, Hds6}]} = nksip_uac:options(C1, "sip:a@external.com", Opts6), - [<<"a,b,d">>] = proplists:get_all_values(<<"Unsupported">>, Hds6), + [<<"a,b,d">>] = proplists:get_all_values(<<"unsupported">>, Hds6), % Force invalid response - Opts7 = [{headers, [{"Nksip-Op", "reply-invalid"}]}, {fields, [reason_phrase]}], + Opts7 = [{headers, [{"x-nk-op", "reply-invalid"}]}, {fields, [reason_phrase]}], nksip_trace:warning("Next warning about a invalid sipreply is expected"), {ok, 500, [{reason_phrase, <<"Invalid SipApp Response">>}]} = nksip_uac:options(C1, "sip:127.0.0.1", Opts7), @@ -189,11 +189,11 @@ timeout() -> Opts2 = [{timer_t1, 10}, {timer_c, 0.5}|Opts] -- [{sipapp_timeout, 0.02}], ok = nksip_sipapp_srv:put_opts(C1, Opts2), - Hds1 = {headers, [{<<"Nk-Sleep">>, 2000}]}, + Hds1 = {headers, [{<<"x-nk-sleep">>, 2000}]}, {ok, 408, [{reason_phrase, <<"No-INVITE Timeout">>}]} = nksip_uac:options(C2, SipC1, [Hds1, {fields, [reason_phrase]}]), - Hds2 = {headers, [{"Nk-Op", busy}, {"Nk-Sleep", 2000}]}, + Hds2 = {headers, [{"x-nk-op", busy}, {"x-nk-sleep", 2000}]}, {ok, 408, [{reason_phrase, <<"Timer C Timeout">>}]} = nksip_uac:invite(C2, SipC1, [Hds2, {fields, [reason_phrase]}]), ok. diff --git a/test/update_endpoint.erl b/test/update_endpoint.erl index 0aa71c2b..b7fda7b7 100644 --- a/test/update_endpoint.erl +++ b/test/update_endpoint.erl @@ -54,11 +54,11 @@ init([Id]) -> invite(ReqId, Meta, From, #state{id=Id, dialogs=Dialogs}=State) -> AppId = {update, Id}, DialogId = nksip_lib:get_value(dialog_id, Meta), - Op = case nksip_request:header(AppId, ReqId, <<"Nk-Op">>) of + Op = case nksip_request:header(AppId, ReqId, <<"x-nk-op">>) of [Op0] -> Op0; _ -> <<"decline">> end, - case nksip_request:header(AppId, ReqId, <<"Nk-Reply">>) of + case nksip_request:header(AppId, ReqId, <<"x-nk-reply">>) of [RepBin] -> {Ref, Pid} = erlang:binary_to_term(base64:decode(RepBin)), State1 = State#state{dialogs=[{DialogId, Ref, Pid}|Dialogs]}; @@ -91,7 +91,7 @@ ack(ReqId, Meta, _From, #state{id=Id, dialogs=Dialogs}=State) -> DialogId = nksip_lib:get_value(dialog_id, Meta), case lists:keyfind(DialogId, 1, Dialogs) of false -> - case nksip_request:header(AppId, ReqId, <<"Nk-Reply">>) of + case nksip_request:header(AppId, ReqId, <<"x-nk-reply">>) of [RepBin] -> {Ref, Pid} = erlang:binary_to_term(base64:decode(RepBin)), Pid ! {Ref, {Id, ack}}; diff --git a/test/update_test.erl b/test/update_test.erl index dec5d460..5b914bfe 100644 --- a/test/update_test.erl +++ b/test/update_test.erl @@ -101,8 +101,8 @@ basic() -> end}, Body = {body, SDP0}, Hds1 = {headers, [ - {"Nk-Op", "basic"}, - {"Nk-Reply", base64:encode(erlang:term_to_binary({Ref, Self}))} + {"x-nk-op", "basic"}, + {<<"x-nk-reply">>, base64:encode(erlang:term_to_binary({Ref, Self}))} ]}, {ok, 200, Values1} = nksip_uac:invite(C1, SipC2, [CB, Hds1, Body]), [{dialog_id, DialogId}] = Values1, @@ -161,7 +161,7 @@ pending() -> end end}, Body = {body, SDP0}, Hds1 = {headers, [ - {"Nk-Op", "pending1"} + {"x-nk-op", "pending1"} ]}, {ok, 200, [{dialog_id, DialogId}]} = nksip_uac:invite(C1, SipC2, [Hds1, Body, CB]), ok = nksip_uac:ack(C1, DialogId, []),