From c807880f7ac73f813b2660ea81a00f7712a4e793 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Mon, 29 Aug 2016 12:39:49 +0200 Subject: Add old mailing list archives --- archives/extend/2014-September/000462.html | 101 +++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 archives/extend/2014-September/000462.html (limited to 'archives/extend/2014-September/000462.html') diff --git a/archives/extend/2014-September/000462.html b/archives/extend/2014-September/000462.html new file mode 100644 index 00000000..f8727d7c --- /dev/null +++ b/archives/extend/2014-September/000462.html @@ -0,0 +1,101 @@ + + + + [99s-extend] Using cowboy_req:body more than once per request + + + + + + + + + + +

[99s-extend] Using cowboy_req:body more than once per request

+ Loïc Hoguin + essen at ninenines.eu +
+ Tue Sep 16 00:22:27 CEST 2014 +

+
+ +
It seems a bit weird to me to read the body and validate it before 
+validating the request itself.
+
+I would explicitly put these checks in the handler directly. This of 
+course means that there is no need to read it twice anymore.
+
+On 09/15/2014 11:24 PM, Paulo F. Oliveira wrote:
+> Hi.
+>
+> I recently implemented a checksum header (X-Checksum) that allows
+> validating the content of a request's body by hash comparison (just to
+> give you some context). I'm using the onrequest hook to affect all
+> requests (and be able to reply appropriately for non-conformance to the
+> hash function result) but can't figure out how to not read the request
+> body twice, i.e. I read it in the onrequest hook but later on need to
+> read it again in the route handler, but I can't (from the manual, for
+> cowboy_req:body: "This function can only be called once. Cowboy will not
+> cache the result of this call."). At the moment, and because the API
+> consumers were in a hurry, the solution I found (I understand it might
+> be an ugly hack), was to read the body, store it in the Req's meta
+> (property body, for example) and then access that property later on,
+> instead of using cowboy_req:body. I'm not quite happy with this solution
+> and was wondering if there is anything more elegant that I can implement.
+>
+> Thanks.
+>
+> Cheers.
+>
+> - Paulo F. Oliveira
+>
+>
+> _______________________________________________
+> Extend mailing list
+> Extend at lists.ninenines.eu
+> https://lists.ninenines.eu/listinfo/extend
+>
+
+-- 
+Loïc Hoguin
+http://ninenines.eu
+
+ + + +
+

+ +
+More information about the Extend +mailing list
+ -- cgit v1.2.3