erlang - Why does my successful streaming response in Webmachine have the status code 500? -


the following code full source of webmachine resource. expected behaviour streaming response should 200, , should string of specified length, entirely composed of letter 'a'.

this string indeed returned body of response, status code 500. how can be?

-module(dummy_binary_resource). -export([init/1, to_html/2]).  -include_lib("webmachine/include/webmachine.hrl").  init(config)->     {ok, config}.  send_streamed_body(remaining) ->     packetsize=1024,     case remaining of         partial when partial =< packetsize ->             {string:chars($a,partial),done};         full ->             {string:chars($a,full), fun() -> send_streamed_body(remaining - packetsize) end}     end.  to_html(reqdata,state)->     pathinfo = wrq:path_info(reqdata),     {ok,sizestring} = dict:find(size,pathinfo),     {size,[]} = string:to_integer(sizestring),     {true,wrq:set_resp_body({stream,send_streamed_body(size)},reqdata),state}. 

the return value incorrect.

the appropriate return value {{halt, 200}, wrq:set_resp_body({stream, send_streamed_body(size)}, reqdata), state}. because request data record has been initialized default code of 500. seem counterintuitive returning "halt" value isn't going stop anything, in fact going signify success.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -