Closed hitecSmartHome closed 1 month ago
I don't understand how it is corrupted. Maybe some menuconfig option is not right.
Maybe the max_resp_headers
config for the server. Will test it
yeah looks like a knob in esp-idf
funny the chopping isnt reported
It wasn't that. I set it to 100 and it still corrupted.
Browsing the menuconfig...
@mhaberler Are you on arduino as a component of idf?
Browsing the menuconfig...
Can't find anything...
So there was a PR https://github.com/hoeken/PsychicHttp/pull/89 Which attempted to free the headers after sending. It then got reverted in this PR https://github.com/hoeken/PsychicHttp/pull/96 but did not merged.
I have removed these lines
for (HTTPHeader header : _headers)
{
free(header.field);
free(header.value);
}
_headers.clear();
from the sendHeaders
method and it started to work.
We probably have to free the headers after sent the whole response and not when the headers are sent.
great job! unfortunately underlines https://github.com/hoeken/PsychicHttp/issues/106
Okay so if we are freeing the headers after the whole response is sent, it works like a charm
esp_err_t PsychicResponse::send() {
// esp-idf makes you set the whole status.
sprintf(_status, "%u %s", _code, http_status_reason(_code));
httpd_resp_set_status(_request->request(), _status);
// our headers too
this->sendHeaders();
// now send it off
esp_err_t err = httpd_resp_send(_request->request(), getContent(), getContentLength());
// did something happen?
if (err != ESP_OK) {
ESP_LOGE(PH_TAG, "Send response failed (%s)", esp_err_to_name(err));
}
// clean up our header variables after send
for (HTTPHeader header : _headers) {
free(header.field);
free(header.value);
}
_headers.clear();
return err;
}
great job! unfortunately underlines #106
Yeah, @hoeken was so passionate about this porject. He was so active and developed this quickly. Sad that he also dissapeared.
let's see if the cleanup can be fitted into the PsychicResponse dtor, that'd be the better locus for cleanup
Oh wait a minute. It is there in the dtor
PsychicResponse::~PsychicResponse() {
// clean up our header variables. we have to do this since httpd_resp_send doesn't store copies
for (HTTPHeader header : _headers) {
free(header.field);
free(header.value);
}
_headers.clear();
}
wtf, there was duplicate code
yep, just noticed that too
so it can be taken out altogether
bingo, https + gzip works, congratulations!
looks as if part of https://github.com/hoeken/PsychicHttp/pull/89 was merged which introduced the duplicate header free
@hitecSmartHome I assume you are running your own fork
I'd propose to wait say a week and see if @hoeken comments
if not, it might make sense to collaborate on a fork
related: https://github.com/hoeken/PsychicHttp/pull/96
funnily https://github.com/hoeken/PsychicHttp/pull/96/commits/413125c98de78da38380fad563330a6fd4da8701 seems to NOT have caused a leak because it removed the dup free
yes it would make sense and I'm in
I have the impression etags work now as well with https://github.com/BCsabaEngine/svelteesp32
re fork: I've penciled in Aug 2 to reconvene
@hitecSmartHome is this contact usable? https://www.hitecsmarthome.hu/en/products
drop me an email with coords at haberlerm at gmail
Yeah, @hoeken was so passionate about this porject. He was so active and developed this quickly. Sad that he also disappeared.
He's on the road a lot, as I recall, at sea sailing yachts from A to B. My guess is that he's in the middle of the Atlantic right now without internet.
hm, a fork can be undone by merging back
@proddy I see "and looking to collaborate on Secure HTTPS and MQTT servers for the ESP32 "in your profile - drop me an email with coords at haberlerm at gmail as well please
Can we not use emails pls? Would be better with a gh discussion or a discord. It is more personal and real time. :D Also any attachment sending is significantly better.
should be taken care of by https://github.com/hoeken/PsychicHttp/commit/b17d8cc9a8d60f4d528293e6fe9d23352bbf3335 and works for me
@hitecSmartHome does this work for you as well?
Will check
Should work now, it's a reversion to the old code where the headers are freed in the destructor
On Wed, Aug 7, 2024, 11:02 HITEC @.***> wrote:
Will check
— Reply to this email directly, view it on GitHub https://github.com/hoeken/PsychicHttp/issues/108#issuecomment-2273813802, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABEHSXPE7JVHZUQWAWCXXTZQJAH7AVCNFSM6AAAAABLQDCB7SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENZTHAYTGOBQGI . You are receiving this because you were mentioned.Message ID: @.***>
Yep. It seems to work for me.
I guess you can close this issue now
Oh sorry I tought it was closed.
I'm sending static content and settings some headers on it but it is corrupted on client side.
I applied some debug logs to the lib but it looks OK.
Also in here
DEBUG LOGS