Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Guard against non-string values of content-type in riak-erlang-client #47

Closed
seancribbs opened this Issue Mar 28, 2012 · 1 comment

Comments

Projects
None yet
1 participant
Contributor

seancribbs commented Mar 28, 2012

Moved from https://issues.basho.com/show_bug.cgi?id=461, reported by @dreverri

Currently functions that accept a content-type do not guard against the value type (list, binary, etc.), however, the encoding process only converts strings.

If a user passes a binary value for content-type, the function accepts the value but the content-type is not present when saving and reading the object:

http://gist.github.com/481900

Possible solutions:

  1. Only accept string values for content-type
  2. Convert other types to strings - this may cause confusion for users who set a binary content-type on an object but receive a string content-type on a get for the same object.

Affected functions:

riakc_obj:new/4
riakc_obj:update_content_type/2
Contributor

seancribbs commented May 30, 2014

Closing, this seems resolved.

24> X3 = riakc_obj:new(<<"b">>, <<"k">>, <<"{\"v\":123}">>, <<"application/json">>).
{riakc_obj,<<"b">>,<<"k">>,undefined,[],
           {dict,1,16,16,8,80,48,
                 {[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],...},
                 {{[],[],[],[],[],[],[],[],[],[],[[<<...>>|...]],[],[],...}}},
           <<"{\"v\":123}">>}
25> riakc_obj:get_update_content_type(X3). 
"application/json"
26> riakc_pb_socket:put(Pid, X3).
ok
27> {ok, X4} = riakc_pb_socket:get(Pid, <<"b">>, <<"k">>).
{ok,{riakc_obj,<<"b">>,<<"k">>,
               <<107,206,97,96,96,96,204,96,202,5,82,28,202,156,255,126,
                 6,119,60,155,150,193,148,...>>,
               [{{dict,3,16,16,8,80,48,
                       {[],[],[],[],[],[],[],[],[],[],[],[],...},
                       {{[],[],[],[],[],[],[],[],[],[],...}}},
                 <<"{\"v\":123}">>}],
               undefined,undefined}}
28> riakc_obj:get_update_content_type(X4).
"application/json"
29> riakc_obj:get_content_type(X4).
"application/json"

@seancribbs seancribbs closed this May 30, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment