8000 Expose webserver's chunk api by d-a-v · Pull Request #7134 · esp8266/Arduino · GitHub
[go: up one dir, main page]

Skip to content

Expose webserver's chunk api #7134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Apr 7, 2020
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
expose hidden WebServer's chunked API
  • Loading branch information
d-a-v committed Mar 4, 2020
commit cc3e01cc180bb86687089af50b449671f34581d6
15 changes: 8 additions & 7 deletions libraries/ESP8266WebServer/examples/FSBrowser/FSBrowser.ino
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,21 @@ void handleFileList() {
return;
}

bool first = true;
// use the same string for every line
String output;
output.reserve(64);
while (dir.next()) {

if (output.length())
// send string from previous iteration
// as an HTTP chunk
server.sendContent(output);
if (output.length()) {
// send string from previous iteration
// as an HTTP chunk
server.sendContent(output);
output = ',';
} else {
output = '[';
}

File entry = dir.openFile("r");
output = first? '[': ',';
first = false;
bool isDir = false;
output += "{\"type\":\"";
output += (isDir) ? "dir" : "file";
Expand Down
0