Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
8fd5c1c0
Commit
8fd5c1c0
authored
Jan 19, 2016
by
Terry Ellison
Browse files
Merge pull request #953 from zhujunsan/dev
Fix example code in HTTP Module Doc
parents
fd234d1d
3983dbca
Changes
1
Hide whitespace changes
Inline
Side-by-side
docs/en/modules/http.md
View file @
8fd5c1c0
...
@@ -20,7 +20,7 @@ Note that it is not possible to execute concurrent HTTP requests using this modu
...
@@ -20,7 +20,7 @@ Note that it is not possible to execute concurrent HTTP requests using this modu
## http.delete()
## http.delete()
Executes a HTTP
delete
request.
Executes a HTTP
DELETE
request.
#### Syntax
#### Syntax
`http.delete(url, headers, body, callback)`
`http.delete(url, headers, body, callback)`
...
@@ -40,7 +40,7 @@ http.delete('https://connor.example.com/john',
...
@@ -40,7 +40,7 @@ http.delete('https://connor.example.com/john',
""
,
""
,
""
,
""
,
function
(
code
,
data
)
function
(
code
,
data
)
if
(
code
<
0
)
if
(
code
<
0
)
then
print
(
"HTTP request failed"
)
print
(
"HTTP request failed"
)
else
else
print
(
code
,
data
)
print
(
code
,
data
)
...
@@ -66,7 +66,7 @@ Executes a HTTP GET request.
...
@@ -66,7 +66,7 @@ Executes a HTTP GET request.
#### Example
#### Example
```
lua
```
lua
http
.
get
(
"https://www.vowstar.com/nodemcu/"
,
nil
,
function
(
code
,
data
)
http
.
get
(
"https://www.vowstar.com/nodemcu/"
,
nil
,
function
(
code
,
data
)
if
(
code
<
0
)
if
(
code
<
0
)
then
print
(
"HTTP request failed"
)
print
(
"HTTP request failed"
)
else
else
print
(
code
,
data
)
print
(
code
,
data
)
...
@@ -96,7 +96,7 @@ http.post('http://json.example.com/something',
...
@@ -96,7 +96,7 @@ http.post('http://json.example.com/something',
'Content-Type: application/json\r\n'
,
'Content-Type: application/json\r\n'
,
'{"hello":"world"}'
,
'{"hello":"world"}'
,
function
(
code
,
data
)
function
(
code
,
data
)
if
(
code
<
0
)
if
(
code
<
0
)
then
print
(
"HTTP request failed"
)
print
(
"HTTP request failed"
)
else
else
print
(
code
,
data
)
print
(
code
,
data
)
...
@@ -126,7 +126,7 @@ http.put('http://db.example.com/items.php?key=deckard',
...
@@ -126,7 +126,7 @@ http.put('http://db.example.com/items.php?key=deckard',
'Content-Type: text/plain\r\n'
,
'Content-Type: text/plain\r\n'
,
'Hello!\nStay a while, and listen...\n'
,
'Hello!\nStay a while, and listen...\n'
,
function
(
code
,
data
)
function
(
code
,
data
)
if
(
code
<
0
)
if
(
code
<
0
)
then
print
(
"HTTP request failed"
)
print
(
"HTTP request failed"
)
else
else
print
(
code
,
data
)
print
(
code
,
data
)
...
@@ -155,11 +155,10 @@ Execute a custom HTTP request for any HTTP method.
...
@@ -155,11 +155,10 @@ Execute a custom HTTP request for any HTTP method.
```
lua
```
lua
http
.
request
(
"https://www.example.com"
,
"HEAD"
,
""
,
""
,
function
(
code
,
data
)
http
.
request
(
"https://www.example.com"
,
"HEAD"
,
""
,
""
,
function
(
code
,
data
)
function
(
code
,
data
)
function
(
code
,
data
)
if
(
code
<
0
)
if
(
code
<
0
)
then
print
(
"HTTP request failed"
)
print
(
"HTTP request failed"
)
else
else
print
(
code
,
data
)
print
(
code
,
data
)
end
end
end
)
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