Skip to content

Commit 70a579e

Browse files
committed
Change previous usage of cloudi_request_info for ResponseInfo parsing to use cloudi_response_info.
1 parent 0aad54c commit 70a579e

File tree

2 files changed

+9
-34
lines changed

2 files changed

+9
-34
lines changed

rebar.config

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
{deps,
55
[{cloudi_core, ".*",
66
{git, "https://github.com/CloudI/cloudi_core.git",
7-
{tag, "v1.8.0"}}},
7+
{branch, "master"}}},
88
{cowboy, ".*",
99
{git, "https://github.com/ninenines/cowboy.git",
1010
{tag, "1.1.2"}}},
1111
{uuid, ".*",
1212
{git, "https://github.com/okeuday/uuid.git",
13-
{tag, "v1.8.0"}}},
13+
{branch, "master"}}},
1414
{trie, ".*",
1515
{git, "https://github.com/okeuday/trie.git",
16-
{tag, "v1.8.0"}}}]}.
16+
{branch, "master"}}}]}.
1717

1818
{erl_opts,
1919
[debug_info,

src/cloudi_http_cowboy1_handler.erl

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
%%%
99
%%% MIT License
1010
%%%
11-
%%% Copyright (c) 2012-2018 Michael Truog <mjtruog at protonmail dot com>
11+
%%% Copyright (c) 2012-2020 Michael Truog <mjtruog at protonmail dot com>
1212
%%%
1313
%%% Permission is hereby granted, free of charge, to any person obtaining a
1414
%%% copy of this software and associated documentation files (the "Software"),
@@ -29,8 +29,8 @@
2929
%%% DEALINGS IN THE SOFTWARE.
3030
%%%
3131
%%% @author Michael Truog <mjtruog at protonmail dot com>
32-
%%% @copyright 2012-2018 Michael Truog
33-
%%% @version 1.7.5 {@date} {@time}
32+
%%% @copyright 2012-2020 Michael Truog
33+
%%% @version 1.8.1 {@date} {@time}
3434
%%%------------------------------------------------------------------------
3535

3636
-module(cloudi_http_cowboy1_handler).
@@ -146,7 +146,6 @@ handle(Req0,
146146
if
147147
(OutputType =:= external) orelse
148148
(OutputType =:= binary) orelse (OutputType =:= list) ->
149-
% cloudi_request_info text_pairs format
150149
{get_query_string_external(QSVals), Req3};
151150
OutputType =:= internal ->
152151
% cloudi_key_value format
@@ -900,12 +899,7 @@ header_content_type(Headers) ->
900899

901900
% format for external services, http headers passed as key-value pairs
902901
headers_external_incoming(L) ->
903-
erlang:iolist_to_binary(headers_external_incoming_text(L)).
904-
905-
headers_external_incoming_text([] = L) ->
906-
L;
907-
headers_external_incoming_text([{K, V} | L]) when is_binary(K) ->
908-
[[K, 0, V, 0] | headers_external_incoming_text(L)].
902+
cloudi_request_info:key_value_new(L, text_pairs).
909903

910904
headers_external_outgoing(<<>>) ->
911905
[];
@@ -917,29 +911,10 @@ headers_external_outgoing([{_, _} | _] = ResponseInfo) ->
917911
ResponseInfo;
918912
headers_external_outgoing(ResponseInfo)
919913
when is_binary(ResponseInfo) ->
920-
headers_external_outgoing_text(binary:split(ResponseInfo, <<0>>, [global])).
921-
922-
headers_external_outgoing_text([<<>>]) ->
923-
[];
924-
headers_external_outgoing_text([K, <<>>]) ->
925-
[{K, <<>>}];
926-
headers_external_outgoing_text([K, V | L]) ->
927-
[{K, V} | headers_external_outgoing_text(L)].
914+
cloudi_response_info:key_value_parse(ResponseInfo, list).
928915

929-
get_query_string_external([]) ->
930-
<<>>;
931916
get_query_string_external(QsVals) ->
932-
erlang:iolist_to_binary(get_query_string_external_text(QsVals)).
933-
934-
get_query_string_external_text([] = L) ->
935-
L;
936-
get_query_string_external_text([{K, V} | L]) ->
937-
if
938-
V =:= true ->
939-
[[K, 0, <<"true">>, 0] | get_query_string_external_text(L)];
940-
is_binary(V) ->
941-
[[K, 0, V, 0] | get_query_string_external_text(L)]
942-
end.
917+
cloudi_request_info:key_value_new(QsVals, text_pairs).
943918

944919
request_time_start() ->
945920
cloudi_timestamp:microseconds_monotonic().

0 commit comments

Comments
 (0)