diff options
author | Loïc Hoguin <[email protected]> | 2016-08-29 12:39:49 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2016-08-29 12:40:03 +0200 |
commit | c807880f7ac73f813b2660ea81a00f7712a4e793 (patch) | |
tree | ba1d09e9b177f230665a80513b33fbd532000ce4 /archives/extend/attachments/20131030 | |
parent | b1df25a7d9cda697513650659b781b55b40898f8 (diff) | |
download | ninenines.eu-c807880f7ac73f813b2660ea81a00f7712a4e793.tar.gz ninenines.eu-c807880f7ac73f813b2660ea81a00f7712a4e793.tar.bz2 ninenines.eu-c807880f7ac73f813b2660ea81a00f7712a4e793.zip |
Add old mailing list archives
Diffstat (limited to 'archives/extend/attachments/20131030')
4 files changed, 172 insertions, 0 deletions
diff --git a/archives/extend/attachments/20131030/0ab7c8ee/attachment.html b/archives/extend/attachments/20131030/0ab7c8ee/attachment.html new file mode 100644 index 00000000..79bd8234 --- /dev/null +++ b/archives/extend/attachments/20131030/0ab7c8ee/attachment.html @@ -0,0 +1,38 @@ +<tt> +<div dir="ltr"><div>Returning 'halt' caused a status code of 204.<br><br></div>Dan.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Oct 30, 2013 at 10:27 AM, Ivan uemlianin <span dir="ltr"><<a href="mailto:[email protected]" target="_blank">[email protected]</a>></span> wrote:<br><br> +<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div>Instead of <<"this body ignored">> can you return the atom halt?</div><div><br><br> +</div><div>#dontevenhaveanyofmycodewithme:(</div><div><br></div><div>Ivan<br><br>--<br>festina lente<div><br></div></div><div><div class="h5"><div><br>On 30 Oct 2013, at 15:58, Daniel Goertzen <<a href="mailto:[email protected]" target="_blank">[email protected]</a>> wrote:<br><br> +<br></div><blockquote type="cite"><div><div dir="ltr">Well, this sort of works.� I tried this in the response handler:<br><div><br>��� ��� ��� {ok, Req2} = cowboy_req:reply(404, [] , <<"this is the body that gets used">>, Req1),<br><br> +��� ��� ��� {<<"this body gets ignored">>, Req2, State};<br><br> +<br><br><br></div><div>The client receives a 404 response, but cowboy crashes:<br><br>=ERROR REPORT==== 8-Sep-2013::22:22:03 ===<br>Error in process <0.131.0> with exit value: {function_clause,[{cowboy_req,reply,[200,[],<<31 bytes>>,{http_req,#Port<0.1208>,ranch_tcp,keepalive,<0.131.0>,<<3 bytes>>,'HTTP/1.1',{{192,168,1,187},51017},<<12 bytes>>,undefined,80,<<24 bytes>>,undefined,<<0 bytes>>,undefined,[{channel_num,3}],[{<<10 bytes>>,<<11 bytes>>},{<<4 bytes>>,<<12 bytes>>},{<<6 bytes>>,<<3 bytes>>}],[{<<17 bytes>>,undefined},{<<13 bytes>>,undefined},{<<19 bytes>>,undefined},{<<8 bytes>>,undefined},{<<6 bytes>>,[... <br><br> +<br> +<br><br><br></div><div>The issue is that the REST wrapper wants to do the cowboy_req:reply(), and when we do the call we cause the wrapper's call to fail. </div><br><div>Dan.<br></div><div><br></div></div><div class="gmail_extra"><br> +<br> +<br><br><div class="gmail_quote">On Tue, Oct 29, 2013 at 4:01 PM, Ivan uemlianin <span dir="ltr"><<a href="mailto:[email protected]" target="_blank">[email protected]</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br> +<br> +<div dir="auto"><div>Sorry for terse but I only have a phone. Why can't you return a 404 here? �Using something like cowboy:reply(404, ...</div><div><br></div><div>Ivan<br><br>--<br>festina lente<div><br></div></div><br> +<div><br> +<div><div><br>On 29 Oct 2013, at 21:25, Daniel Goertzen <<a href="mailto:[email protected]" target="_blank">[email protected]</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><br> +<div><div><div>My situation is that I have a rest handler that may fail due to invalid url segments.� Example situation:<br><br><br><span style="font-family:courier new,monospace">init(_Transport, _Req, _Opts) -><br><br> +������� {upgrade, protocol, cowboy_rest}.<br><br>content_types_provided(Req, State) -><br>��� {[{<<"application/json">>, get_json}], Req, State}.<br><br>get_json(Req0, State) -><br>��� {Params, Req1} = lists:mapfoldl(fun cowboy_req:binding/2, Req0, [param1, param2, param3, ....]),<br><br> +<br> +<br> +<br>��� case catch other_module:request(Params) of<br>��� ��� {'EXIT', {badarg, _}} -><br></span></div><div><span style="font-family:courier new,monospace">��� ��� ��� hmmm, Params were bad and I would like to return a 404 code now.<br><br> +<br> +<br> +</span></div><div><span style="font-family:courier new,monospace">�� � �� Result -><br>��� ��� ��� {jiffy:encode(Result), Req1, State}<br>��� end.<br></span><br><br><br></div><div>So I would like to return a 404 code when my underlying request function fails, but it appears my choices are:<br><br> +<br> +<br> +</div><div><br>- return a 200 (ok) response with data.<br></div><div>- crash and cause a 500 (Internal Server Error) response to be returned.� Not exactly the sentiment I want.<br></div><div><div><br><br></div><div>Is there some other way to cause a 404 response?<br><br> +<br> +<br> +<br></div><div>I realize I could add path constraint functions, but I will be replicating logic from my underlying request function.� Furthermore, the constraint functions consider parameters in isolation, so that won't work if the validity of parameters is coupled.<br><br> +<br> +<br> +</div><div><br></div><div>Thanks,<br>Dan.<br></div></div></div></div></div><br> +</div></blockquote></div></div><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Extend mailing list</span><br><span><a href="mailto:[email protected]" target="_blank">[email protected]</a></span><br><br> +<br> +<span><a href="http://lists.ninenines.eu:81/listinfo/extend" target="_blank">http://lists.ninenines.eu:81/listinfo/extend</a></span><br></div></blockquote></div></blockquote></div><br></div><br> +</div></blockquote></div></div></div></blockquote></div><br></div><br> + +</tt> diff --git a/archives/extend/attachments/20131030/3ea4ac64/attachment.html b/archives/extend/attachments/20131030/3ea4ac64/attachment.html new file mode 100644 index 00000000..751be332 --- /dev/null +++ b/archives/extend/attachments/20131030/3ea4ac64/attachment.html @@ -0,0 +1,88 @@ +<tt> +<div dir="ltr"><div>That's what I was looking for, thanks!<br><br></div><div>Dan.<br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Oct 30, 2013 at 10:25 AM, Tilman Holschuh <span dir="ltr"><<a href="mailto:[email protected]" target="_blank">[email protected]</a>></span> wrote:<br><br> +<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Why not let resource_exists/2 return false when your resource does not exist? You will get 404 on false. This way you separate the implementation for turning your data to json from checking if the request went to the correct resource.<br><br> +<br> +<span class="HOEnZb"><font color="#888888"><br><br> +- Tilman<br><br> +</font></span><div class="HOEnZb"><div class="h5"><br><br> +On 2013-10-30, at 7:58 AM, Daniel Goertzen wrote:<br><br> +<br><br> +> Well, this sort of works. �I tried this in the response handler:<br><br> +><br><br> +> � � � � � � {ok, Req2} = cowboy_req:reply(404, [] , <<"this is the body that gets used">>, Req1),<br><br> +> � � � � � � {<<"this body gets ignored">>, Req2, State};<br><br> +><br><br> +><br><br> +><br><br> +> The client receives a 404 response, but cowboy crashes:<br><br> +><br><br> +> =ERROR REPORT==== 8-Sep-2013::22:22:03 ===<br><br> +> Error in process <0.131.0> with exit value: {function_clause,[{cowboy_req,reply,[200,[],<<31 bytes>>,{http_req,#Port<0.1208>,ranch_tcp,keepalive,<0.131.0>,<<3 bytes>>,'HTTP/1.1',{{192,168,1,187},51017},<<12 bytes>>,undefined,80,<<24 bytes>>,undefined,<<0 bytes>>,undefined,[{channel_num,3}],[{<<10 bytes>>,<<11 bytes>>},{<<4 bytes>>,<<12 bytes>>},{<<6 bytes>>,<<3 bytes>>}],[{<<17 bytes>>,undefined},{<<13 bytes>>,undefined},{<<19 bytes>>,undefined},{<<8 bytes>>,undefined},{<<6 bytes>>,[...<br><br> +<br> +><br><br> +><br><br> +><br><br> +> The issue is that the REST wrapper wants to do the cowboy_req:reply(), and when we do the call we cause the wrapper's call to fail.<br><br> +><br><br> +> Dan.<br><br> +><br><br> +><br><br> +><br><br> +> On Tue, Oct 29, 2013 at 4:01 PM, Ivan uemlianin <<a href="mailto:[email protected]">[email protected]</a>> wrote:<br><br> +> Sorry for terse but I only have a phone. Why can't you return a 404 here? �Using something like cowboy:reply(404, ...<br><br> +><br><br> +> Ivan<br><br> +><br><br> +> --<br><br> +> festina lente<br><br> +><br><br> +><br><br> +> On 29 Oct 2013, at 21:25, Daniel Goertzen <<a href="mailto:[email protected]">[email protected]</a>> wrote:<br><br> +><br><br> +>> My situation is that I have a rest handler that may fail due to invalid url segments. �Example situation:<br><br> +>><br><br> +>><br><br> +>> init(_Transport, _Req, _Opts) -><br><br> +>> � � � � {upgrade, protocol, cowboy_rest}.<br><br> +>><br><br> +>> content_types_provided(Req, State) -><br><br> +>> � � {[{<<"application/json">>, get_json}], Req, State}.<br><br> +>><br><br> +>> get_json(Req0, State) -><br><br> +>> � � {Params, Req1} = lists:mapfoldl(fun cowboy_req:binding/2, Req0, [param1, param2, param3, ....]),<br><br> +>><br><br> +>> � � case catch other_module:request(Params) of<br><br> +>> � � � � {'EXIT', {badarg, _}} -><br><br> +>> � � � � � � hmmm, Params were bad and I would like to return a 404 code now.<br><br> +>> � � � � Result -><br><br> +>> � � � � � � {jiffy:encode(Result), Req1, State}<br><br> +>> � � end.<br><br> +>><br><br> +>><br><br> +>><br><br> +>> So I would like to return a 404 code when my underlying request function fails, but it appears my choices are:<br><br> +>><br><br> +>> - return a 200 (ok) response with data.<br><br> +>> - crash and cause a 500 (Internal Server Error) response to be returned. �Not exactly the sentiment I want.<br><br> +>><br><br> +>><br><br> +>> Is there some other way to cause a 404 response?<br><br> +>><br><br> +>> I realize I could add path constraint functions, but I will be replicating logic from my underlying request function. �Furthermore, the constraint functions consider parameters in isolation, so that won't work if the validity of parameters is coupled.<br><br> +<br> +>><br><br> +>> Thanks,<br><br> +>> Dan.<br><br> +>> _______________________________________________<br><br> +>> Extend mailing list<br><br> +>> <a href="mailto:[email protected]">[email protected]</a><br><br> +>> <a href="http://lists.ninenines.eu:81/listinfo/extend" target="_blank">http://lists.ninenines.eu:81/listinfo/extend</a><br><br> +><br><br> +> _______________________________________________<br><br> +> Extend mailing list<br><br> +> <a href="mailto:[email protected]">[email protected]</a><br><br> +> <a href="http://lists.ninenines.eu:81/listinfo/extend" target="_blank">http://lists.ninenines.eu:81/listinfo/extend</a><br><br> +<br><br> +</div></div></blockquote></div><br></div><br> + +</tt> diff --git a/archives/extend/attachments/20131030/460453c8/attachment.html b/archives/extend/attachments/20131030/460453c8/attachment.html new file mode 100644 index 00000000..ee5dfd0f --- /dev/null +++ b/archives/extend/attachments/20131030/460453c8/attachment.html @@ -0,0 +1,23 @@ +<tt> +<div dir="ltr">Well, this sort of works.� I tried this in the response handler:<br><div><br>��� ��� ��� {ok, Req2} = cowboy_req:reply(404, [] , <<"this is the body that gets used">>, Req1),<br>��� ��� ��� {<<"this body gets ignored">>, Req2, State};<br><br> +<br><br><br></div><div>The client receives a 404 response, but cowboy crashes:<br><br>=ERROR REPORT==== 8-Sep-2013::22:22:03 ===<br>Error in process <0.131.0> with exit value: {function_clause,[{cowboy_req,reply,[200,[],<<31 bytes>>,{http_req,#Port<0.1208>,ranch_tcp,keepalive,<0.131.0>,<<3 bytes>>,'HTTP/1.1',{{192,168,1,187},51017},<<12 bytes>>,undefined,80,<<24 bytes>>,undefined,<<0 bytes>>,undefined,[{channel_num,3}],[{<<10 bytes>>,<<11 bytes>>},{<<4 bytes>>,<<12 bytes>>},{<<6 bytes>>,<<3 bytes>>}],[{<<17 bytes>>,undefined},{<<13 bytes>>,undefined},{<<19 bytes>>,undefined},{<<8 bytes>>,undefined},{<<6 bytes>>,[... <br><br> +<br><br><br></div><div>The issue is that the REST wrapper wants to do the cowboy_req:reply(), and when we do the call we cause the wrapper's call to fail. </div><br><div>Dan.<br></div><div><br></div></div><div class="gmail_extra"><br> +<br><br><div class="gmail_quote">On Tue, Oct 29, 2013 at 4:01 PM, Ivan uemlianin <span dir="ltr"><<a href="mailto:[email protected]" target="_blank">[email protected]</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br> +<div dir="auto"><div>Sorry for terse but I only have a phone. Why can't you return a 404 here? �Using something like cowboy:reply(404, ...</div><div><br></div><div>Ivan<br><br>--<br>festina lente<div><br></div></div><div><br> +<div class="h5"><div><br>On 29 Oct 2013, at 21:25, Daniel Goertzen <<a href="mailto:[email protected]" target="_blank">[email protected]</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><br> +<div><div><div>My situation is that I have a rest handler that may fail due to invalid url segments.� Example situation:<br><br><br><span style="font-family:courier new,monospace">init(_Transport, _Req, _Opts) -><br><br> +������� {upgrade, protocol, cowboy_rest}.<br><br>content_types_provided(Req, State) -><br>��� {[{<<"application/json">>, get_json}], Req, State}.<br><br>get_json(Req0, State) -><br>��� {Params, Req1} = lists:mapfoldl(fun cowboy_req:binding/2, Req0, [param1, param2, param3, ....]),<br><br> +<br> +<br>��� case catch other_module:request(Params) of<br>��� ��� {'EXIT', {badarg, _}} -><br></span></div><div><span style="font-family:courier new,monospace">��� ��� ��� hmmm, Params were bad and I would like to return a 404 code now.<br><br> +<br> +</span></div><div><span style="font-family:courier new,monospace">�� � �� Result -><br>��� ��� ��� {jiffy:encode(Result), Req1, State}<br>��� end.<br></span><br><br><br></div><div>So I would like to return a 404 code when my underlying request function fails, but it appears my choices are:<br><br> +<br> +</div><div><br>- return a 200 (ok) response with data.<br></div><div>- crash and cause a 500 (Internal Server Error) response to be returned.� Not exactly the sentiment I want.<br></div><div><div><br><br></div><div>Is there some other way to cause a 404 response?<br><br> +<br> +<br></div><div>I realize I could add path constraint functions, but I will be replicating logic from my underlying request function.� Furthermore, the constraint functions consider parameters in isolation, so that won't work if the validity of parameters is coupled.<br><br> +<br> +</div><div><br></div><div>Thanks,<br>Dan.<br></div></div></div></div></div><br> +</div></blockquote></div></div><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Extend mailing list</span><br><span><a href="mailto:[email protected]" target="_blank">[email protected]</a></span><br><br> +<span><a href="http://lists.ninenines.eu:81/listinfo/extend" target="_blank">http://lists.ninenines.eu:81/listinfo/extend</a></span><br></div></blockquote></div></blockquote></div><br></div><br> + +</tt> diff --git a/archives/extend/attachments/20131030/6e8ec2f0/attachment.html b/archives/extend/attachments/20131030/6e8ec2f0/attachment.html new file mode 100644 index 00000000..e7d1542c --- /dev/null +++ b/archives/extend/attachments/20131030/6e8ec2f0/attachment.html @@ -0,0 +1,23 @@ +<tt> +<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Instead of <<"this body ignored">> can you return the atom halt?</div><div><br></div><div>#dontevenhaveanyofmycodewithme:(</div><div><br></div><div>Ivan<br><br>--<br>festina lente<div><br></div></div><div><br>On 30 Oct 2013, at 15:58, Daniel Goertzen <<a href="mailto:[email protected]">[email protected]</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">Well, this sort of works. I tried this in the response handler:<br><div><br> {ok, Req2} = cowboy_req:reply(404, [] , <<"this is the body that gets used">>, Req1),<br> {<<"this body gets ignored">>, Req2, State};<br><br> +<br><br><br></div><div>The client receives a 404 response, but cowboy crashes:<br><br>=ERROR REPORT==== 8-Sep-2013::22:22:03 ===<br>Error in process <0.131.0> with exit value: {function_clause,[{cowboy_req,reply,[200,[],<<31 bytes>>,{http_req,#Port<0.1208>,ranch_tcp,keepalive,<0.131.0>,<<3 bytes>>,'HTTP/1.1',{{192,168,1,187},51017},<<12 bytes>>,undefined,80,<<24 bytes>>,undefined,<<0 bytes>>,undefined,[{channel_num,3}],[{<<10 bytes>>,<<11 bytes>>},{<<4 bytes>>,<<12 bytes>>},{<<6 bytes>>,<<3 bytes>>}],[{<<17 bytes>>,undefined},{<<13 bytes>>,undefined},{<<19 bytes>>,undefined},{<<8 bytes>>,undefined},{<<6 bytes>>,[... <br><br> +<br><br><br></div><div>The issue is that the REST wrapper wants to do the cowboy_req:reply(), and when we do the call we cause the wrapper's call to fail. </div><br><div>Dan.<br></div><div><br></div></div><div class="gmail_extra"><br> +<br><br><div class="gmail_quote">On Tue, Oct 29, 2013 at 4:01 PM, Ivan uemlianin <span dir="ltr"><<a href="mailto:[email protected]" target="_blank">[email protected]</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br> +<div dir="auto"><div>Sorry for terse but I only have a phone. Why can't you return a 404 here? Using something like cowboy:reply(404, ...</div><div><br></div><div>Ivan<br><br>--<br>festina lente<div><br></div></div><div><br> +<div class="h5"><div><br>On 29 Oct 2013, at 21:25, Daniel Goertzen <<a href="mailto:[email protected]" target="_blank">[email protected]</a>> wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr"><br> +<div><div><div>My situation is that I have a rest handler that may fail due to invalid url segments. Example situation:<br><br><br><span style="font-family:courier new,monospace">init(_Transport, _Req, _Opts) -><br><br> + {upgrade, protocol, cowboy_rest}.<br><br>content_types_provided(Req, State) -><br> {[{<<"application/json">>, get_json}], Req, State}.<br><br>get_json(Req0, State) -><br> {Params, Req1} = lists:mapfoldl(fun cowboy_req:binding/2, Req0, [param1, param2, param3, ....]),<br><br> +<br> +<br> case catch other_module:request(Params) of<br> {'EXIT', {badarg, _}} -><br></span></div><div><span style="font-family:courier new,monospace"> hmmm, Params were bad and I would like to return a 404 code now.<br><br> +<br> +</span></div><div><span style="font-family:courier new,monospace"> Result -><br> {jiffy:encode(Result), Req1, State}<br> end.<br></span><br><br><br></div><div>So I would like to return a 404 code when my underlying request function fails, but it appears my choices are:<br><br> +<br> +</div><div><br>- return a 200 (ok) response with data.<br></div><div>- crash and cause a 500 (Internal Server Error) response to be returned. Not exactly the sentiment I want.<br></div><div><div><br><br></div><div>Is there some other way to cause a 404 response?<br><br> +<br> +<br></div><div>I realize I could add path constraint functions, but I will be replicating logic from my underlying request function. Furthermore, the constraint functions consider parameters in isolation, so that won't work if the validity of parameters is coupled.<br><br> +<br> +</div><div><br></div><div>Thanks,<br>Dan.<br></div></div></div></div></div><br> +</div></blockquote></div></div><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Extend mailing list</span><br><span><a href="mailto:[email protected]" target="_blank">[email protected]</a></span><br><br> +<span><a href="http://lists.ninenines.eu:81/listinfo/extend" target="_blank">http://lists.ninenines.eu:81/listinfo/extend</a></span><br></div></blockquote></div></blockquote></div><br></div><br> +</div></blockquote></body></html> +</tt> |