Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
08921c98
Commit
08921c98
authored
Jan 24, 2016
by
Marcel Stör
Browse files
Transfer HTTP client examples to lua_examples/
Fixes #941
parent
2e16e3af
Changes
1
Hide whitespace changes
Inline
Side-by-side
lua_examples/http-client.lua
0 → 100644
View file @
08921c98
-- Support HTTP and HTTPS, For example
-- HTTP POST Example with JSON header and body
http
.
post
(
"http://somewhere.acceptjson.com/"
,
"Content-Type: application/json\r\n"
,
"{\"
hello
\
":\"
world
\
"}"
,
function
(
code
,
data
)
print
(
code
)
print
(
data
)
end
)
-- HTTPS GET Example with NULL header
http
.
get
(
"https://www.vowstar.com/nodemcu/"
,
""
,
function
(
code
,
data
)
print
(
code
)
print
(
data
)
end
)
-- You will get
-- > 200
-- hello nodemcu
-- HTTPS DELETE Example with NULL header and body
http
.
delete
(
"https://10.0.0.2:443"
,
""
,
""
,
function
(
code
,
data
)
print
(
code
)
print
(
data
)
end
)
-- HTTPS PUT Example with NULL header and body
http
.
put
(
"https://testput.somewhere/somewhereyouput.php"
,
""
,
""
,
function
(
code
,
data
)
print
(
code
)
print
(
data
)
end
)
-- HTTP RAW Request Example, use more HTTP/HTTPS request method
http
.
request
(
"http://www.apple.com:80/library/test/success.html"
,
"GET"
,
""
,
""
,
function
(
code
,
data
)
print
(
code
)
print
(
data
)
end
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment