Welcome! Log In Create A New Profile

Advanced

[WM26] - HTTPGetResult() issues

Posted by JP 
JP
[WM26] - HTTPGetResult() issues
December 07, 2021 03:43PM
Hi All

I've been developing an app and testing under Android. All working fine. Now I want to test under iOS. One of the immediate problems I am hitting is with the HTTPGetResult() function. The app makes a call to my server using HTTPRequest() and the server receives a valid request and sends back a reply. Server-side all working fine.

Now in the app I always get what appears to be an empty string. I understand the string coming back from the server must be ANSI String as the server is Windows. So I have tried to receive the string into an ANSI STRING variable and then convert the ANSI STRING variable to a UNICODE variable. But nothing seems to work - the result is always an empty string. e.g. I have tried this:

bufSServer_Response_Ansi_Buffer is Buffer = HTTPGetResult()
bufSServer_Response_Unicode_Buffer is Buffer = bufSServer_Response_Ansi_Buffer.AnsiToUnicode()

Both variables however seem to be empty.

If I check the HTTPHeader of the returned packet it says:

HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/html
Server: Microsoft 118
Date...
Conneciton:Close
Content-Length: 0

Any suggestions?

Thanks



Edited 4 time(s). Last edit at 12/07/2021 04:06PM by JP.
Argus
Re: [WM26] - HTTPGetResult() issues
December 07, 2021 04:27PM
If I remember correctly, for iOS, you need to do some magic with UTF8, not ansi/unicode...

I know that all that is detailed in several thread in the french pcsoft forum, so you should find the details there
JP
Re: [WM26] - HTTPGetResult() issues
December 07, 2021 07:04PM
Thanks again, Argus. Sadly I dont read French ... sad smiley
Argus
Re: [WM26] - HTTPGetResult() issues
December 07, 2021 09:56PM
perhaps, but you can search for iOS httprequest in the mobile forum, and use google translate for the reading part
JP
Re: [WM26] - HTTPGetResult() issues
December 08, 2021 09:26AM
Hi Argus

I searched for ios HTTPRequest() as you suggested and found the below message suggested :

[forum.pcsoft.fr]

A user has created a procedure to handle the conversion as follows:

Procedure WS_Android_IOS_HTTPGetResult()

// Variable
bufResHTTP is Buffer
sHTTPResult is string

// Retrieves the result of the query
bufResHTTP = HTTPGetResult( httpResult )

// Result in UTF8 em iOS Apple
IF IniOSMode() = True OR IniOSSimulatorMode() = True OR IniOSEmulatorMode() = True THEN

IF StringCount( bufResHTTP , “ISO-8859-1” , IgnoreCase ) = 0 THEN

sHTTPResult = UTF8ToString( bufResHTTP )

ELSE

sHTTPResult = AnsiToUnicode( bufResHTTP )

END

ELSE IF InAndroidMode() = True OR InAndroidSimulatorMode() = True OR InAndroidEmulatorMode() = True THEN

// Result in Android
sHTTPResult = bufResHTTP

END

RESULT( sHTTPResult )


However, I have tried this and all variations fail. i.e. whether I convert the HTTPResult using UTF8ToString() or using AnsiToUnicode() or just take the result as returned I still get what appears to be an empty string when testing on the iPhone. Under the emulator it works fine.
Re: [WM26] - HTTPGetResult() issues
December 08, 2021 10:16AM
Hi JP,

>Thanks again, Argus. Sadly I dont read French ...

me too. But you can use Google Chrome with the live translate options (french->english) and you can read the forum like this here. Works like a charm.

regards Michael
JP
Re: [WM26] - HTTPGetResult() issues
December 08, 2021 11:35AM
Thanks Michael. Yes I am trying that now but cannot find a solution. Found 1 message when searching iOS HTTPRequest but the solution offered does not seem to work for me.
JP
Re: [WM26] - HTTPGetResult() issues - [SOLVED]
December 08, 2021 01:52PM
[SOLVED]

The WIndows server is returning some content as an ANSI string. All that is required is to receive that content into a ANSI STRING in WinDev Mobile. However, the fault was that the script returning the content did not have a content-type header excplcitly stating that the content was charset=windows-1252. Once this was added the iOS WM app understood the content and could process it.

Thanks
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: