Просмотр исходного кода

fix: httpplus处理chunked编码时吃掉了末尾的一个字节

Wendal Chen 2 лет назад
Родитель
Сommit
6c92cc9eb4
2 измененных файлов с 5 добавлено и 4 удалено
  1. 4 3
      demo/httpplus/main.lua
  2. 1 1
      script/libs/httpplus.lua

+ 4 - 3
demo/httpplus/main.lua

@@ -118,9 +118,10 @@ function test_httpplus()
     log.info("http", code, resp)
     if code == 200 then
         log.info("http", "headers", json.encode(resp.headers))
-        log.info("http", "body", resp.body:query():toHex())
-        log.info("http", "body", resp.body:query())
-        log.info("http", "body", json.decode(resp.body:query()))
+        local body = resp.body:query()
+        log.info("http", "body", body:toHex())
+        log.info("http", "body", body)
+        log.info("http", "body", json.decode(body:trim()))
         -- log.info("http", "body", json.decode(resp.body))
     end
 end

+ 1 - 1
script/libs/httpplus.lua

@@ -337,7 +337,7 @@ local function resp_parse(opts)
                         -- opts.log(TAG, "chunked分片长度2", clen)
                         if clen == 0 then
                             -- 末尾了
-                            opts.rx_buff:resize(coffset - 1)
+                            opts.rx_buff:resize(coffset)
                             crun = false
                         else
                             -- 先删除chunked块