Guest User

httprequesttests

a guest
Dec 19th, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.79 KB | None | 0 0
  1. //________________________________
  2. //
  3. //  Made by feha, 20??
  4. //
  5. //________________________________
  6.  
  7. // Note, this file is run in a shared environment.
  8.  
  9.  
  10.  
  11. // Shared
  12. Print("Shared1")
  13.  
  14.  
  15.  
  16. if Server then
  17.     // Server
  18.     Print("Server")
  19.    
  20.     local testdata = {
  21.         first = "first",
  22.         number = 42,
  23.         bool = true,
  24.     }
  25.     Shared.SendHTTPRequest("www.google.com", "PUT", testdata,
  26.         function(...)
  27.             Print("PUT callback!")
  28.             for k,v in pairs({...}) do
  29.                 Print(tostring(k) .. " ; type = " .. type(v))
  30.                
  31.                 // Cant use Print, it errors for some reason, seems to have to do with string.format
  32.                 //Print("PUT: " .. tostring(k) .. " ; value = " .. tostring(v))
  33.                 Shared.Message("PUT: " .. tostring(k) .. " ; value = " .. tostring(v))
  34.             end
  35.         end
  36.     )
  37.    
  38.    
  39.     Shared.SendHTTPRequest("www.google.com", "POST", testdata,
  40.         function(...)
  41.             Print("POST callback!")
  42.             for k,v in pairs({...}) do
  43.                 Print(tostring(k) .. " ; type = " .. type(v))
  44.                
  45.                 // Cant use Print, it errors for some reason, seems to have to do with string.format
  46.                 //Print("POST: " .. tostring(k) .. " ; value = " .. tostring(v))
  47.                 Shared.Message("POST: " .. tostring(k) .. " ; value = " .. tostring(v))
  48.             end
  49.         end
  50.     )
  51.    
  52.    
  53.     Shared.SendHTTPRequest("www.google.com", "GET", testdata,
  54.         function(...)
  55.             Print("GET callback!")
  56.             for k,v in pairs({...}) do
  57.                 Print(tostring(k) .. " ; type = " .. type(v))
  58.                
  59.                 // Cant use Print, it errors for some reason, seems to have to do with string.format
  60.                 //Print("GET: " .. tostring(k) .. " ; value = " .. tostring(v))
  61.                 Shared.Message("GET: " .. tostring(k) .. " ; value = " .. tostring(v))
  62.             end
  63.         end
  64.     )
  65.    
  66. elseif Client then
  67.     // Client
  68.     Print("Client")
  69.    
  70.    
  71. elseif Predict then
  72.     // Predict
  73.     Print("Predict")
  74.    
  75.    
  76. end
  77.  
  78.  
  79. // Shared
  80. Print("Shared2")
Advertisement
Add Comment
Please, Sign In to add comment