You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
Using the HTTP Server class, if the headersComplete callback returns false on a PUT request, a response provided by the subsequent prepareResponse callback is not sent out. The Socket is reset instead.
Steps to Reproduce
Run an adaptation of the HTTP server example httpserverputfile as follows:
ver } from "http"
import { File } from "file"
import Net from "net"
new Server({}).callback = function (message, value) {
switch (message) {
// case Server.status: // request status received
// let path = value; // file path is HTTP path
// File.delete(path);
// this.file = new File(path, true);
// break;
case Server.headersComplete: // prepare for request body
return false // ignore request body
// case Server.requestFragment: // request body fragment
// this.read(ArrayBuffer)
// break
case Server.prepareResponse: // request body received
return { status: 400, body: "I did not like this file" }
}
}
trace(`Available on Wi-Fi "${Net.get("SSID")}"\n`)
trace(
`curl --data-binary "@/users/[your directory path here]/test.txt" http://${Net.get(
"IP"
)}/test.txt -v\n`
)
(The manifest can be used unchanged from the original example)
3. Perform a PUT request with some file, like:
> curl --data-binary @README.md http://192.168.0.216/test.txt -v
* Trying 192.168.0.216:80...
* Connected to 192.168.0.216 (192.168.0.216) port 80
> POST /test.txt HTTP/1.1
> Host: 192.168.0.216
> User-Agent: curl/8.4.0
> Accept: */*
> Content-Length: 1913
> Content-Type: application/x-www-form-urlencoded
>
< HTTP/1.1 400 Bad Request
< connection: close
< content-length: 24
<
* Closing connection
I did not like this file⏎
Other information
As far as I can tell:
HTTP Server does not read the request body when the callback returns false
it simply sends the response and closes the socket
lwip gets the close holding unconsumed rx buffers and probably also an untransmitted tx buffer and instead of sorting everything out just resets the connection?
The text was updated successfully, but these errors were encountered:
Moddable SDK version: 4.3
Target device: esp32
Description
Using the HTTP Server class, if the
headersComplete
callback returnsfalse
on a PUT request, a response provided by the subsequentprepareResponse
callback is not sent out. The Socket is reset instead.Steps to Reproduce
httpserverputfile
as follows:(The manifest can be used unchanged from the original example)
3. Perform a PUT request with some file, like:
this.close()
to close the socket. Then re-run the curl and as soon as the breakpoint is hit press the continue button. Observe how the request/response completes correctly.Other information
As far as I can tell:
The text was updated successfully, but these errors were encountered: