Page 1 of 1
Display invisible chars in IDE
Posted: Wed Oct 31, 2018 4:03 pm
by infratec
Hi,
If I use a header map with Content-Type and other 'normal' headers it works a it should.
But this:
Code: Select all
InitNetwork()
NewMap Header$()
Header$("Content-Type") = "application/json"
Header$("x-auth-token") = "123"
HTTPRequest(#PB_HTTP_Post, "http://www.purebasic.fr", "Test", 0, Header$())
Results in:
x-auth-token: \342\200\213\342\200\213123\r\n
Content-Type: application/json\r\n
0090 41 63 63 65 70 74 3a 20 2a 2f 2a 0d 0a 78 2d 61 Accept: */*..x-a
00a0 75 74 68 2d 74 6f 6b 65 6e 3a 20 e2 80 8b e2 80 uth-token: â..â.
00b0 8b 31 32 33 0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 .123..Content-Ty
00c0 70 65 3a 20 61 70 70 6c 69 63 61 74 69 6f 6e 2f pe: application/
00d0 6a 73 6f 6e 0d 0a 43 6f 6e 74 65 6e 74 2d 4c 65 json..Content-Le
Independent of the string it puts $e2808b $e2808b in front of the string.
Very strange, since other custom headers works as expected.
Bernd
Re: PB 5.70b2 HTTPMemory() Header Map
Posted: Sat Nov 03, 2018 10:20 am
by wayne-c
I encountered a probably similar bug when sending a custom "Authorization" header with Base64-encoded Username:Password; as soon as there are accents (e.g. "é") inside the Password, the authorization is rejected by the service. I did not check with Wireshark what is actually transferred but I assume now that this could be the same error than yours and the Header is not transferred correctly!
Re: PB 5.70b2 HTTPMemory() Header Map
Posted: Sun Nov 04, 2018 10:29 am
by infratec
I did further investigations:
I changed the code and used libcurl directly.
With very strange results.
First I declared a constant for the authcode, since it is fixed in my application.
Code: Select all
*headers = curl_slist_append(*headers, "X-Auth-Token: " + #X_Auth_Token$)
It fails in the same way.
The I thought: may be the string buffer is not avalaible when it is needed
and I used an extra variable.
Code: Select all
Token$ = "X-Auth-Token: " + #X_Auth_Token$
*headers = curl_slist_append(*headers, Token$)
It fails in the same way.
Only working version:
Code: Select all
*headers = curl_slist_append(*headers, "X-Auth-Token: 123456"
I use
Code: Select all
curl_slist_append(slist.i, string.p-utf8)
for the import.
So 2 possibilities:
1. Something with p-utf8 is not 100% Ok
2. A bug in libcurls curl_slist_append()
I searched in the web for 2. but I found no informations about a bug.
Also a curl.exe request works as expected (Ok, there is also the complete string at once provided)
I have no chance to go deeper inside.
Bernd
Re: PB 5.70b2 HTTPMemory() Header Map
Posted: Mon Nov 19, 2018 2:16 pm
by Fred
I will take a look
Re: PB 5.70b2 HTTPMemory() Header Map
Posted: Mon Nov 19, 2018 10:16 pm
by Fred
I spend some time on this one, but it's not a PB bug: your string contains some hidden characters and PB create it like this in datasection for "123":
As you can see, there is 2 extra character in the literal string. Just delete the string completely from the IDE and retype it and it will be gone.
Re: PB 5.70b2 HTTPMemory() Header Map
Posted: Tue Nov 20, 2018 8:34 am
by infratec
Hi Fred,
thank you for your time.
Originally I copied the string from an e-mail.
Then it was not working and I deleted it from the end via backspace and added 123.
Unfortunately the 2 hidden characters stayed.
But how should I know something about these characters? They are invisible.
Very strange.
I'll check if there are 24 different invisible characters available, then I'll write a procedure which allows to send 'invisible' text via e-mails
Bernd
Re: [Solved]PB 5.70b2 HTTPMemory() Header Map
Posted: Tue Nov 20, 2018 8:44 am
by infratec
Re: [Solved]PB 5.70b2 HTTPMemory() Header Map
Posted: Tue Nov 20, 2018 9:21 am
by Fred
May be the IDE should display these, dunno if we can force scintilla to do so.
Edit: #SCI_SETREPRESENTATION seems the way to go, I will add some characters mapping in the IDE so it will be displayed