SmingRTOS icon indicating copy to clipboard operation
SmingRTOS copied to clipboard

HttpRequest::getBody() is empty for IE XMLHttpRequest

Open tius2000 opened this issue 9 years ago • 6 comments

IE seems to sends XMLHttpRequest as two TCP packets (see https://josephscott.org/archives/2009/08/xmlhttprequest-xhr-uses-multiple-packets-for-http-post). I could verify this for a simple request with IE11 on a win7 box using wireshark.

However, this seems to confuse Sming, it will report an empty request body. The webserver seems to handle fragmented packets not correctly.

A possible workaround might be to use GET instead of POST.

tius2000 avatar Jun 04 '16 21:06 tius2000

@tius2000 : I think the issue you are describing will be taken care of in the update @patrickjahns is preparing which adds http_upload functionality.

hreintke avatar Jun 04 '16 22:06 hreintke

Great! Thank you for the super-fast feedback @hreintke :-)

tius2000 avatar Jun 04 '16 22:06 tius2000

@tius2000 try my ported fix by @patrickjahns https://github.com/avr39-ripe/SmingRTOS/commit/5b46bbe335f36098d1d22ee5a7ca8fd83ccd8e2e

avr39-ripe avatar Jun 04 '16 23:06 avr39-ripe

@avr39-ripe: Sorry, I'm new to git - how can I apply your fix to my cloned local SmingRTOS files?

tius2000 avatar Jun 05 '16 12:06 tius2000

https://github.com/avr39-ripe/SmingRTOS/commit/5b46bbe335f36098d1d22ee5a7ca8fd83ccd8e2e.patch

here is patch. download it into SmingRTOS dir, then patch < patch_nam.patch and viola :)

avr39-ripe avatar Jun 05 '16 19:06 avr39-ripe

Thank you very much @avr39-ripe! I applied the patch and XMLHttpRequest works with IE now, too :+1:

However, there is a small side effect. The return value of getBody has changed from const char * to String. This means that an additional copy of the data needs to be allocated for parsing the posted data with JsonBuffer::parseObject(). While this no problem for my application, it might be inefficient for larger strings.

tius2000 avatar Jun 10 '16 22:06 tius2000