Browse Source

using mg.read() only for POST requests

Sergey Lyubka 12 năm trước cách đây
mục cha
commit
e645b33b6c
1 tập tin đã thay đổi với 7 bổ sung1 xóa
  1. 7 1
      examples/lua/prime_numbers.lp

+ 7 - 1
examples/lua/prime_numbers.lp

@@ -24,7 +24,13 @@ Content-Type: text/html
  <form method="POST" ><input type="text" name="t1"/><input type="submit"></form>
 
  <pre>
-   POST data: [<?  mg.write(mg.read())?>]
+   POST data: [<?
+      local post_data = ''
+      if mg.request_info.request_method == 'POST' then
+        post_data = mg.read()
+      end
+      mg.write(post_data)
+    ?>]
    request method: [<? mg.write(mg.request_info.request_method) ?>]
    IP/port: [<? mg.write(mg.request_info.remote_ip, ':',
                          mg.request_info.remote_port) ?>]