net.http: Fix to send query part of URL to server

Thu, 15 Jan 2009 04:08:06 +0000

author
Matthew Wild <mwild1@gmail.com>
date
Thu, 15 Jan 2009 04:08:06 +0000
changeset 719
b1eb112478b8
parent 718
aa78dfb26593
child 720
8f22e9fb2291

net.http: Fix to send query part of URL to server

net/http.lua file | annotate | diff | comparison | revisions
--- a/net/http.lua	Thu Jan 15 04:36:35 2009 +0500
+++ b/net/http.lua	Thu Jan 15 04:08:06 2009 +0000
@@ -142,7 +142,14 @@
 		return nil, err;
 	end
 	
-	req.write((req.method or "GET ")..req.path.." HTTP/1.0\r\n");
+	local request_line = { req.method or "GET", " ", req.path, " HTTP/1.1\r\n" };
+	
+	if req.query then
+		t_insert(request_line, 4, "?");
+		t_insert(request_line, 5, req.query);
+	end
+	
+	req.write(t_concat(request_line));
 	local t = { [2] = ": ", [4] = "\r\n" };
 	if custom_headers then
 		for k, v in pairs(custom_headers) do

mercurial