Conversation
|
This PR adds a This example was also built in order to serve as a MRE for these 2 issues:
Endpoint using AwsResponseFiller curl -v http://192.168.4.1/1 | grep -o '.' | sort | uniq -c
5652 A
4308 B
5760 C
280 DESP32: Endpoint with a custom response: curl -v http://192.168.4.1/2 | grep -o '.' | sort | uniq -c
5675 A
4308 B
2888 C
3129 DESP32: So everything works fine in the example. |
dd92360 to
a3f612a
Compare
|
@ESP32Async/devs : build pass. I am going to merge in main do that we can rebase and use these examples as a base to work on for the prs / fixes. Let me know if something is off otherwise i will merge. Thank you! |
|
looks OK to me, but with a quick test on my side it also does not reproduce the issue - strange. Will play with it more tomorrow |
|
For now i will merge - these are good examples we do not have. And besides they will be helpful for your tests ;-) |
|
I cracked it. So this is how it works: If you change your class this way it will fail 100%. class CustomResponse : public AsyncAbstractResponse {
public:
explicit CustomResponse() {
_code = 200;
_contentType = "text/plain";
_sendContentLength = false;
// add some useless headers
addHeader("Clear-Site-Data", "Clears browsing data (e.g., cookies, storage, cache) associated with the requesting website.");
addHeader("No-Vary-Search", "Specifies a set of rules that define how a URL's query parameters will affect cache matching. These rules dictate whether the same URL with different URL parameters should be saved as separate browser cache entries");
}
bool _sourceValid() const override {
return true;
}
size_t _fillBuffer(uint8_t *buf, size_t buflen) override {
if (fillChar == NULL){
fillChar = 'A';
return RESPONSE_TRY_AGAIN;
}
if (_sent == RESPONSE_TRY_AGAIN) {
Serial.println("Simulating temporary unavailability of data...");
_sent = 0;
return RESPONSE_TRY_AGAIN;
}
size_t remaining = totalResponseSize - _sent;
if (remaining == 0) {
return 0;
}
if (buflen > remaining) {
buflen = remaining;
}
Serial.printf("Filling '%c' @ sent: %u, buflen: %u\n", fillChar, _sent, buflen);
std::fill_n(buf, buflen, static_cast<uint8_t>(fillChar));
_sent += buflen;
fillChar = (fillChar == 'Z') ? 'A' : fillChar + 1;
return buflen;
}
private:
char fillChar = NULL; //'A';
size_t _sent = 0;
}; |
|
@vortigont : thanks ! I will push an update to the example in the working branch of your PR. |
No description provided.