lib/nitcorn: allows access to POST raw body
authorAlexandre Terrasa <alexandre@moz-code.org>
Wed, 17 Dec 2014 20:57:56 +0000 (15:57 -0500)
committerAlexandre Terrasa <alexandre@moz-code.org>
Wed, 17 Dec 2014 21:05:57 +0000 (16:05 -0500)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

lib/nitcorn/http_request.nit

index e4628af..f580b54 100644 (file)
@@ -3,6 +3,7 @@
 # Copyright 2013 Frederic Sevillano
 # Copyright 2013 Jean-Philippe Caissy <jpcaissy@piji.ca>
 # Copyright 2014 Alexis Laferrière <alexis.laf@xymus.net>
+# Copyright 2014 Alexandre Terrasa <alexandre@moz-code.org>
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -46,6 +47,9 @@ class HttpRequest
        # The header of this request
        var header = new HashMap[String, String]
 
+       # The raw body of the request.
+       var body = ""
+
        # The content of the cookie of this request
        var cookie = new HashMap[String, String]
 
@@ -142,6 +146,7 @@ class HttpRequestParser
 
                # POST args
                if http_request.method == "POST" then
+                       http_request.body = body
                        var lines = body.split_with('&')
                        for line in lines do if not line.trim.is_empty then
                                var parts = line.split_once_on('=')