diff options
Diffstat (limited to '_build/static/archives/extend/2014-July/000409.html')
-rw-r--r-- | _build/static/archives/extend/2014-July/000409.html | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/_build/static/archives/extend/2014-July/000409.html b/_build/static/archives/extend/2014-July/000409.html new file mode 100644 index 00000000..5969aed9 --- /dev/null +++ b/_build/static/archives/extend/2014-July/000409.html @@ -0,0 +1,126 @@ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<HTML> + <HEAD> + <TITLE> [99s-extend] [cowboy REST] returning {true, URL} to PUT + </TITLE> + <LINK REL="Index" HREF="index.html" > + <LINK REL="made" HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20%5Bcowboy%20REST%5D%20returning%20%7Btrue%2C%20URL%7D%20to%20PUT&In-Reply-To=%3CCAH2nEUi9qkU4tjeYMNzQeppJ4me3p3z2UPqfSB-dQ6G4x_ExyA%40mail.gmail.com%3E"> + <META NAME="robots" CONTENT="index,nofollow"> + <style type="text/css"> + pre { + white-space: pre-wrap; /* css-2.1, curent FF, Opera, Safari */ + } + </style> + <META http-equiv="Content-Type" content="text/html; charset=us-ascii"> + <LINK REL="Previous" HREF="000408.html"> + <LINK REL="Next" HREF="000410.html"> + </HEAD> + <BODY BGCOLOR="#ffffff"> + <H1>[99s-extend] [cowboy REST] returning {true, URL} to PUT</H1> + <B>Samuel</B> + <A HREF="mailto:extend%40lists.ninenines.eu?Subject=Re%3A%20%5B99s-extend%5D%20%5Bcowboy%20REST%5D%20returning%20%7Btrue%2C%20URL%7D%20to%20PUT&In-Reply-To=%3CCAH2nEUi9qkU4tjeYMNzQeppJ4me3p3z2UPqfSB-dQ6G4x_ExyA%40mail.gmail.com%3E" + TITLE="[99s-extend] [cowboy REST] returning {true, URL} to PUT">samuelrivas at gmail.com + </A><BR> + <I>Tue Jul 8 13:32:45 CEST 2014</I> + <P><UL> + <LI>Previous message: <A HREF="000408.html">[99s-extend] [cowboy REST] returning {true, URL} to PUT +</A></li> + <LI>Next message: <A HREF="000410.html">[99s-extend] [cowboy REST] returning {true, URL} to PUT +</A></li> + <LI> <B>Messages sorted by:</B> + <a href="date.html#409">[ date ]</a> + <a href="thread.html#409">[ thread ]</a> + <a href="subject.html#409">[ subject ]</a> + <a href="author.html#409">[ author ]</a> + </LI> + </UL> + <HR> +<!--beginarticle--> +<PRE>Ok, thanks. That should probably be mentioned in the documentation of +content_types_accepted, as it says {true, URI} is a valid output for +the provided function. + +Just out of curiosity from a non-so-expert in REST. The API spec +(which I am not the author of) says the PUT call should create a +resource with a unique id and return the URI of the created resource +in the Location header. That is something like PUT /some/resource +should return /some/resource/1234 in the Location. some/resource is +fixed but 1234 would be generated for each instance of /some/resource. +Is that considered nonsensical? + +On 8 July 2014 11:57, Loïc Hoguin <<A HREF="https://lists.ninenines.eu/listinfo/extend">essen at ninenines.eu</A>> wrote: +><i> It's not enabled for PATCH or PUT because it makes little sense for them. +</I>><i> PATCH and PUT are typically used directly on the URI of the resource, even +</I>><i> when creating it. While you can return a "better URI" for the created +</I>><i> resource for them, this should be seen as a special case rather than the +</I>><i> norm. You can still do it by setting the location header manually and Cowboy +</I>><i> will react accordingly. +</I>><i> +</I>><i> +</I>><i> On 07/08/2014 09:12 AM, Samuel wrote: +</I>>><i> +</I>>><i> Hi, +</I>>><i> +</I>>><i> According to the documentation I should be able to return a new +</I>>><i> location when handling a PUT request when using cowboy_rest protocol: +</I>>><i> +</I>>><i> The AcceptResource value is the name of the callback that will be +</I>>><i> called if the +</I>>><i> content-type matches. It is defined as follow. +</I>>><i> +</I>>><i> Value type: true | {true, URL} | false +</I>>><i> +</I>>><i> That works for "true" and "false" but not for "{true, URL}", in that +</I>>><i> case the Ranch listener crashes badly[1]. +</I>>><i> +</I>>><i> Looking into cowboy_rest.erl I see that the {true, URL} form is +</I>>><i> restricted to POST requests: +</I>>><i> <A HREF="https://github.com/extend/cowboy/blob/master/src/cowboy_rest.erl#L784">https://github.com/extend/cowboy/blob/master/src/cowboy_rest.erl#L784</A> +</I>>><i> +</I>>><i> Is that intentional or should I submit a patch to add at least PUT and +</I>>><i> PATCH to that condition (or remove all of them if that is not guarding +</I>>><i> against something horrible)? +</I>>><i> +</I>>><i> Regards +</I>>><i> +</I>>><i> [1] Ranch crash log: +</I>>><i> Ranch listener http_acceptor had connection process started with +</I>>><i> cowboy_protocol:start_link/4 at <0.2660.0> exit with reason: +</I>>><i> +</I>>><i> {{case_clause,{{true,"/url"},{http_req,#Port<0.15864>,ranch_tcp,keepalive,<0.2660.0>,<<"PUT">>,'HTTP/1.1',{{127,0,0,1},56983},<<"localhost">>,undefined,8080,<<"/order">>,undefined,<<>>,undefined,[],[{<<"user-agent">>,<<"curl/7.22.0 +</I>>><i> (x86_64-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 +</I>>><i> libidn/1.23 +</I>>><i> librtmp/2.3">>},{<<"host">>,<<"localhost:8080">>},{<<"accept">>,<<"*/*">>},{<<"content-type">>,<<"application/json">>}],[{<<"content-type">>,{<<"application">>,<<"json">>,[]}},{<<"if-modified-since">>,undefined},{<<"if-none-match">>,undefined},{<<"if-unmodified-since">>,undefined},{<<"if-match">>,undefined},{<<"accept">>,[{{<<"*">>,<<"*">>,[]},1000,[]}]}],undefined,[{charset,undefined},{media_type,{<<"text">>,<<"html">>,[]}}],waiting,undefined,<<>>,false,waiting,[{<<"content-type">>,[<<"text">>,<<"/">>,<<"html">>,<<>>]}],<<>>,undefined},{state}}},[{cowboy_rest,process_content_type,3,[{file,"src/cowboy_rest.erl"},{line,780}]},{cowboy_protocol,execute,4,[{file,"src/cowboy_protocol.erl"},{line,529}]}]} +</I>>><i> +</I>><i> +</I>><i> -- +</I>><i> Loïc Hoguin +</I>><i> <A HREF="http://ninenines.eu">http://ninenines.eu</A> +</I> + + +-- +Samuel +</PRE> + + +<!--endarticle--> + <HR> + <P><UL> + <!--threads--> + <LI>Previous message: <A HREF="000408.html">[99s-extend] [cowboy REST] returning {true, URL} to PUT +</A></li> + <LI>Next message: <A HREF="000410.html">[99s-extend] [cowboy REST] returning {true, URL} to PUT +</A></li> + <LI> <B>Messages sorted by:</B> + <a href="date.html#409">[ date ]</a> + <a href="thread.html#409">[ thread ]</a> + <a href="subject.html#409">[ subject ]</a> + <a href="author.html#409">[ author ]</a> + </LI> + </UL> + +<hr> +<a href="https://lists.ninenines.eu/listinfo/extend">More information about the Extend +mailing list</a><br> +</body></html> |