Hi all,
The new command HTTPRequest is not yet documented,
however when used, the IDE status bar displays:
HTTPRequest(Type, URL$ [, Data$ [, Flags [, Headers()]]]) - Executes an HTTP request.
What are the possible values for Flag ? All examples put 0
I ask this because I am testing a WebService in French and whose accents in return do not pass with HTTPRequest
But:
- Accents are OK well in a browser (Firefox)
- Accents are OK with a ReceiveHTTPFile()
I used the header "Header$("Accept-Language") = "fr_FR"" as indicated in the webservice provider documentation.
The emitted data in return are in UTF-8.
The file created by SaveJson is in UTF-8
But in reply:
è => è
ô => ô
I also created a header identical to the one used by Firefox, but without any effect.
There are not many accented characters, so I can change them afterwards, but I would like to know if this can be solved with the fourth undocumented parameter ?
PS. If someone had the URL of a public webservice returning data with accents, I would be interested to be able to make a comparison. (I can't post my current test URL because access is limited.)
[SOLVED] HttpRequest() What are the possible values for Flag
[SOLVED] HttpRequest() What are the possible values for Flag
Last edited by Marc56us on Wed Nov 07, 2018 11:24 am, edited 1 time in total.
Re: HttpRequest() What are the possible values for Flag
Code: Select all
Con = HTTPRequest(#PB_HTTP_Get, "https://www.purebasic.com/french/", "", #PB_UTF8)
If Con
Response$ = HTTPInfo(Con, #PB_HTTP_Response)
Debug Response$
EndIf
Works also:
Code: Select all
Con = HTTPRequest(#PB_HTTP_Get, "https://www.purebasic.com/french/")
Re: HttpRequest() What are the possible values for Flag
You're right, and it works for accents, with or without #PB_UTF8, so the problem is elsewhere
My webservice use JSON in reply, so CreateJSON()?, ParseJSON() or SaveJSON()
ShowLibraryViewer("json", 0) show wrongs accents, so error is not in SaveJson()
Code: Select all
CreateJSON(0)
ParseJSON(0, Reponse$)
ShowLibraryViewer("json", 0)
CallDebugger
SaveJSON(0, Json_File$, #PB_JSON_PrettyPrint)
Thanks, guys.
Re: HttpRequest() What are the possible values for Flag
Show me your Result$ from your HTTPRequest()
If it is correct, then the JSON stuff should not produce wrong characters.
If it is correct, then the JSON stuff should not produce wrong characters.
Re: HttpRequest() What are the possible values for Flag
Found
This is HTTPInfo() who need flag #PB_UTF8 (for accents), even if reply is send as Utf-8
Protected Reponse$ = HTTPInfo(HTTPRequest, #PB_HTTP_Response, #PB_UTF8)
This is HTTPInfo() who need flag #PB_UTF8 (for accents), even if reply is send as Utf-8
Protected Reponse$ = HTTPInfo(HTTPRequest, #PB_HTTP_Response, #PB_UTF8)
Re: [SOLVED] HttpRequest() What are the possible values for
In another post, Fred says, that the flags are the same like ReceiveHTTPFile...
so that have nothing to do with UTF8 or something like that.
so that have nothing to do with UTF8 or something like that.
Code: Select all
#PB_HTTP_Asynchronous: starts the download asynchronously.
#PB_HTTP_NoRedirect : don't follow automatic redirections.
Re: [SOLVED] HttpRequest() What are the possible values for
But only for HTTPRequest() and not for HTTPInfo()