File: socket.dpatch

package info (click to toggle)
lua-soap 1.0b-6
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 112 kB
  • ctags: 33
  • sloc: sh: 66; makefile: 24
file content (48 lines) | stat: -rw-r--r-- 1,507 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /bin/sh /usr/share/dpatch/dpatch-run
## module.dpatch by Enrico Tassi <gareuselesinge@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: No description.

@DPATCH@
diff -urNad trunk~/http.lua trunk/http.lua
--- trunk~/http.lua	2004-12-02 18:39:36.000000000 +0100
+++ trunk/http.lua	2007-07-21 18:50:03.000000000 +0200
@@ -4,7 +4,8 @@
 -- $Id: http.lua,v 1.1 2004/03/24 19:27:37 tomas Exp $
 ---------------------------------------------------------------------
 
-require"luasocket"
+require"socket.http"
+require"ltn12"
 require"soap"
 
 local post = socket.http.post
@@ -17,17 +18,23 @@
 -- @param namespace
 ---------------------------------------------------------------------
 function soap.http.call (url, namespace, method, entries, headers)
-	local body, headers, code, err = post {
+	local body = {}
+	local data = soap.encode (namespace, method, entries, headers)
+	local rc, code, headers = socket.http.request {
 		url = url,
-		body = soap.encode (namespace, method, entries, headers),
+		method = "POST",
+		source = ltn12.source.string(data),
 		headers = {
 			["Content-type"] = "text/xml",
 			["SOAPAction"] = '"'..method..'"',
+			["Content-length"] = tostring(string.len(data)),
 		},
+		sink = ltn12.sink.table(body)
 	}
-	if tonumber (code) == 200 then
+	body = table.concat(body)
+	if rc == 1 and tonumber (code) == 200 then
 		return soap.decode (body)
 	else
-		error ((err or code).."\n\n"..body)
+		error (code.."\n\n"..body)
 	end
 end