WIZnet Developer Forum

Safari on IOS ajax request in segmented frames

Hi! I spent too many time to resolve my problem with http server from IOlibrary and Safari AJAX request.
The problem is: very often received AJAX packets from Safari (IOS) does not contain body data.

I set up WireShark with ethernet HUB to capture all packet to wiznet. And i found difference in packets from chrome and safari. Safari packets contain 2 segments and wiznet receive only first packet with headers. I use this function len = recv(s, (uint8_t *)http_request, len); Only first segment receive fronm bufer. How i can resolve this problem?
@Eugeny can you help me? Russian language is my native language-))

For me it looks like Chrome sends data within single frame, but safari may split to two. And the first cause coming to my mind is that your W5500 code waits for data arrival, takes it further and does not check for more data arrival before considering the first chunk of data. If I am corrent the problem is in your W5500 driver code which expects whole data arrival through first reading of non-zero RX_RSR, while it is not the case and more data will arrive later.

Thank you for reply @Eugeny . I discovered that problem appeare when I connect to http server on w5500 from ios device. Chrome on IOS device have the same problem. But safari on Mac book work fine. I did not write recv function. I just take it from wiznet http server library. IOS tcp stack may be split in 2 packets ajax request. Where I can read full size of http packet?

The problem is not in library, it is in logic of your code. Library returns data or pointers available at the specific time, but it is your application logic to decide if that you have received is a complete data, and you must go to recv function again and wait for more information (with timeout of course). For example, HTTP response ends with CRLFCRLF, and whatever number of times recv returns with data, application must call it again until receives this magic sequence, only after this HTTP response is deemed complete, and application will base its behavior on the contents of this HTTP response. Before this full data receive happens, HTTP response data should be considered as invalid.

@Eugeny what size receive recvsize = getSn_RX_RSR(sn); when the first segment of packet received?
Only size of first part (segment) ? After that i must parse http packet and decide does i need another parts of http packet ? and call recv function to catch rest of data?
I suppouse that packets with relative sequence number glued in wiz buffer because http is 7 level, may be i am wrong?
This is recv function recv function

Normally yes.

Correct.

You do not deal with “packets” if you use socket in TCP mode, you just deal with count of bytes in the buffer and the data in the buffer.

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.