diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 600b14b..f8087b5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,7 +6,7 @@ jobs: runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v5 - name: luacheck uses: lunarmodules/luacheck@v1 @@ -14,11 +14,14 @@ jobs: tests: strategy: matrix: - lua-version: ["5.1.5", "5.2.4", "5.3.6", "5.4.4"] + lua-version: ["5.1.5", "5.2.4", "5.3.6", "5.4.8"] runs-on: ubuntu-latest steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v5 + + - name: install readline + run: sudo apt-get install -y libreadline-dev - name: localua run: | diff --git a/LICENSE.txt b/LICENSE.txt index 084dd91..e61f237 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,5 +1,5 @@ Copyright (C) 2012-2013 by Moodstocks SAS -Copyright (C) 2014-2022 by Pierre Chapuis +Copyright (C) since 2014 by Pierre Chapuis Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 330449e..ab3ef59 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,15 @@ rq.url = "http://httpbin.org/post" local b, c, h = http.request(rq) ``` +Example setting extra headers (here Authorization): + +```lua +local rq = mp.gen_request({myfile = {name = "myfilename", data = "some data"}}) +rq.url = "http://httpbin.org/post" +rq.headers.Authorization = "Bearer SomeToken42" +local b, c, h = http.request(rq) +``` + ## Bugs Non-ASCII part names are not supported. @@ -91,5 +100,5 @@ Note that non-ASCII file names are supported since version 1.2. ## Copyright -- Copyright (c) 2012-2013 Moodstocks SAS -- Copyright (c) 2014-2022 Pierre Chapuis +- Copyright (c) 2012 - 2013 Moodstocks SAS +- Copyright (c) since 2014 Pierre Chapuis diff --git a/multipart-post.test.lua b/multipart-post.test.lua index cebaf94..a6092ac 100644 --- a/multipart-post.test.lua +++ b/multipart-post.test.lua @@ -7,7 +7,7 @@ local enc = (require "multipart-post").encode local J do -- Find a JSON parser local ok, json = pcall(require, "cjson") - if not ok then ok, json = pcall(require, "json") end + if not ok then ok, json = pcall(require, "lunajson") end J = json.decode assert(ok and J, "no JSON parser found :(") end @@ -33,6 +33,7 @@ T:start("gen_request"); do }, foo = "bar", } + rq.headers.Authorization = "Bearer SomeToken42" rq.url = "http://httpbin.org/post" rq.sink = ltn12.sink.table(r) @@ -47,6 +48,7 @@ T:start("gen_request"); do ltn12file="ltn12 data" }) T:eq(r.form, {foo = "bar"}) + T:eq(r.headers.Authorization, "Bearer SomeToken42") end; T:done() T:start("encode"); do diff --git a/rockspec/multipart-post-scm-1.rockspec b/rockspec/multipart-post-scm-1.rockspec index 8566ea1..9cfb901 100644 --- a/rockspec/multipart-post-scm-1.rockspec +++ b/rockspec/multipart-post-scm-1.rockspec @@ -29,7 +29,7 @@ build = { test_dependencies = { "cwtest", - "luajson", + "lunajson", } test = {