Skip to content

Commit 1b74535

Browse files
committed
demonstrate ability to set headers
#9
1 parent b2681e4 commit 1b74535

3 files changed

Lines changed: 14 additions & 3 deletions

File tree

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Copyright (C) 2012-2013 by Moodstocks SAS
2-
Copyright (C) 2014-2022 by Pierre Chapuis
2+
Copyright (C) since 2014 by Pierre Chapuis
33

44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ rq.url = "http://httpbin.org/post"
6868
local b, c, h = http.request(rq)
6969
```
7070

71+
Example setting extra headers (here Authorization):
72+
73+
```lua
74+
local rq = mp.gen_request({myfile = {name = "myfilename", data = "some data"}})
75+
rq.url = "http://httpbin.org/post"
76+
rq.headers.Authorization = "Bearer SomeToken42"
77+
local b, c, h = http.request(rq)
78+
```
79+
7180
## Bugs
7281

7382
Non-ASCII part names are not supported.
@@ -91,5 +100,5 @@ Note that non-ASCII file names are supported since version 1.2.
91100

92101
## Copyright
93102

94-
- Copyright (c) 2012-2013 Moodstocks SAS
95-
- Copyright (c) 2014-2022 Pierre Chapuis
103+
- Copyright (c) 2012 - 2013 Moodstocks SAS
104+
- Copyright (c) since 2014 Pierre Chapuis

multipart-post.test.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ T:start("gen_request"); do
3333
},
3434
foo = "bar",
3535
}
36+
rq.headers.Authorization = "Bearer SomeToken42"
3637

3738
rq.url = "http://httpbin.org/post"
3839
rq.sink = ltn12.sink.table(r)
@@ -47,6 +48,7 @@ T:start("gen_request"); do
4748
ltn12file="ltn12 data"
4849
})
4950
T:eq(r.form, {foo = "bar"})
51+
T:eq(r.headers.Authorization, "Bearer SomeToken42")
5052
end; T:done()
5153

5254
T:start("encode"); do

0 commit comments

Comments
 (0)