소스 검색

update:取消demo注释

Dozingfiretruck 3 년 전
부모
커밋
a94f08e1e8
1개의 변경된 파일29개의 추가작업 그리고 29개의 파일을 삭제
  1. 29 29
      demo/socket/EC618/http_demo.lua

+ 29 - 29
demo/socket/EC618/http_demo.lua

@@ -2,39 +2,39 @@
 local function testTask()
 
     -- GET request, task内的同步操作
-    local code, headers, body = http.request("GET","http://site0.cn/api/httptest/simple/time")--.wait()
-    -- log.info("http.get", code, headers, body)
+    local code, headers, body = http.request("GET","http://site0.cn/api/httptest/simple/time").wait()
+    log.info("http.get", code, headers, body)
 
-    -- -- POST request
-    -- local req_headers = {}
-    -- req_headers["Content-Type"] = "application/json"
-    -- local body = json.encode({name="LuatOS"})
-    -- local code, headers, body = http.request("POST","http://site0.cn/api/httptest/simple/date", 
-    --         req_headers,
-    --         body -- POST请求所需要的body, string, zbuff, file均可
-    -- ).wait()
-    -- log.info("http.post", code, headers, body)
+    -- POST request
+    local req_headers = {}
+    req_headers["Content-Type"] = "application/json"
+    local body = json.encode({name="LuatOS"})
+    local code, headers, body = http.request("POST","http://site0.cn/api/httptest/simple/date", 
+            req_headers,
+            body -- POST请求所需要的body, string, zbuff, file均可
+    ).wait()
+    log.info("http.post", code, headers, body)
 
-    -- -- POST and download, task内的同步操作
-    -- local opts = {}                 -- 额外的配置项
-    -- opts["dst"] = "/data.bin"       -- 下载路径,可选
-    -- opts["timeout"] = 30            -- 超时时长,单位秒,可选
-    -- opts["adapter"] = socket.ETH0  -- 使用哪个网卡,可选
-    -- local code, headers, body = http.request("POST","http://site0.cn/api/httptest/simple/date", 
-    --         {}, -- 请求所添加的 headers, 可以是nil
-    --         "", 
-    --         opts
-    -- ).wait()
-    -- log.info("http.post", code, headers, body) -- 只返回code和headers
+    -- POST and download, task内的同步操作
+    local opts = {}                 -- 额外的配置项
+    opts["dst"] = "/data.bin"       -- 下载路径,可选
+    opts["timeout"] = 30            -- 超时时长,单位秒,可选
+    opts["adapter"] = socket.ETH0  -- 使用哪个网卡,可选
+    local code, headers, body = http.request("POST","http://site0.cn/api/httptest/simple/date", 
+            {}, -- 请求所添加的 headers, 可以是nil
+            "", 
+            opts
+    ).wait()
+    log.info("http.post", code, headers, body) -- 只返回code和headers
 
-    -- local f = io.open("/data.bin", "rb")
-    -- if f then
-    --     local data = f:read("*a")
-    --     log.info("fs", "data", data, data:toHex())
-    -- end
+    local f = io.open("/data.bin", "rb")
+    if f then
+        local data = f:read("*a")
+        log.info("fs", "data", data, data:toHex())
+    end
     
-    -- -- GET request, 开个task让它自行执行去吧, 不管执行结果了
-    -- sys.taskInit(http.request("GET","http://site0.cn/api/httptest/simple/time").wait)
+    -- GET request, 开个task让它自行执行去吧, 不管执行结果了
+    sys.taskInit(http.request("GET","http://site0.cn/api/httptest/simple/time").wait)
 end
 
 function httpDemo()