Skip to content

Commit

Permalink
Change headers name to lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
kalta committed Mar 19, 2014
1 parent d221c6e commit 10a156e
Show file tree
Hide file tree
Showing 49 changed files with 416 additions and 416 deletions.
4 changes: 2 additions & 2 deletions samples/nksip_pbx/src/nksip_pbx_sipapp.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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 = [
Expand Down
10 changes: 5 additions & 5 deletions samples/nksip_tutorial/src/nksip_tutorial.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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, "<sip:127.0.0.1;transport=tls>", [{pass, "1234"}]),

{ok,200,[{<<"Contact">>, [<<"<sip:[email protected]:5070>;expires=3600">>]}]} =
{ok,200,[{<<"contact">>, [<<"<sip:[email protected]:5070>;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]),

Expand All @@ -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, "<sip:127.0.0.1;lr>"}]),
{ok,200,[{<<"Nksip-Id">>, [<<"client2">>]}]} =
{ok,200,[{<<"nksip-id">>, [<<"client2">>]}]} =
nksip_uac:options(client1, "sips:client2@nksip",
[{route, "<sip:127.0.0.1;lr>"}, {pass, "1234"},
{fields, [<<"Nksip-Id">>]}]),
{fields, [<<"nksip-id">>]}]),

{ok,488,[{dialog_id, _}]} =
nksip_uac:invite(client2, "sip:client1@nksip", [{route, "<sips:127.0.0.1;lr>"}]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}.

Expand Down
8 changes: 4 additions & 4 deletions src/nksip_auth.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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">>)).


%% ===================================================================
Expand Down
4 changes: 2 additions & 2 deletions src/nksip_call_dialog.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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
[] ->
[];
Expand All @@ -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
[] ->
[];
Expand Down
2 changes: 1 addition & 1 deletion src/nksip_call_fork.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
[
Expand Down
2 changes: 1 addition & 1 deletion src/nksip_call_proxy.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
22 changes: 11 additions & 11 deletions src/nksip_call_timer.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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};
Expand Down Expand Up @@ -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;
_ ->
Expand All @@ -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,
Expand All @@ -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);
Expand All @@ -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,
Expand All @@ -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;

Expand All @@ -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};
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/nksip_call_uac_dialog.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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}]
Expand Down
2 changes: 1 addition & 1 deletion src/nksip_call_uac_reply.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/nksip_call_uas_dialog.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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">>}]
}.
Expand Down
10 changes: 5 additions & 5 deletions src/nksip_call_uas_process.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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);
[] ->
Expand All @@ -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] ->
Expand Down Expand Up @@ -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
Expand All @@ -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}],
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/nksip_call_uas_reply.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
4 changes: 2 additions & 2 deletions src/nksip_outbound.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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">>}};
[] ->
Expand Down
2 changes: 1 addition & 1 deletion src/nksip_publish.erl
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ make_reg(Body) ->

%% @private
reply(Tag, Expires) ->
{ok, [{<<"SIP-ETag">>, Tag}], <<>>, [{expires, Expires}]}.
{ok, [{<<"sip-etag">>, Tag}], <<>>, [{expires, Expires}]}.


%% @private
Expand Down
4 changes: 2 additions & 2 deletions src/nksip_registrar.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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=[]}.


Expand Down
12 changes: 6 additions & 6 deletions src/nksip_reply.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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}]};
Expand All @@ -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};
Expand All @@ -352,23 +352,23 @@ 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};
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}]};
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};
Expand All @@ -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) ->
Expand Down
Loading

0 comments on commit 10a156e

Please sign in to comment.