Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
uses: actions/checkout@v5

- name: luacheck
uses: lunarmodules/luacheck@v1

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: |
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
4 changes: 3 additions & 1 deletion multipart-post.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion rockspec/multipart-post-scm-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ build = {

test_dependencies = {
"cwtest",
"luajson",
"lunajson",
}

test = {
Expand Down