login about faq

CLEAR

LOCAL loReq

LOCAL loHttp

LOCAL lnSuccess

LOCAL lcRequestText

LOCAL loResp

loReq = CreateObject('Chilkat.HttpRequest')

loHttp = CreateObject('Chilkat.Http')

_password = 'komplex'

_user = 'alfeus'

lnSuccess = loHttp.UnlockComponent("xxx")

IF (lnSuccess <> 1) THEN

=MESSAGEBOX(loHttp.LastErrorText)

QUIT

ENDIF

loReq.HttpVerb = 'GET'

loReq.Charset = "utf-8"

loReq.ContentType = "application/jsonrequest"

loReq.SendCharset = 1

loReq.Path = "/api/customer/1870"

loReq.AddHeader("Content-Type","application/json")

loReq.AddHeader("charset","utf-8")

loReq.LoadBodyFromString(" ","utf-8")

loHttp.login = _user

loHttp.password = _password

loHttp.AcceptCharset = "utf-8"

port = 8443 ssl = 1

loResp = loHttp.SynchronousRequest("https://z1.net.e-net.sk",port,ssl,loReq)

IF (loResp = NULL ) THEN

? loHttp.LastErrorText

ELSE

? loResp.BodyStr

ENDIF

RELEASE loReq

RELEASE loHttp

RELEASE lnSuccess

RELEASE lcRequestText

RELEASE loResp

return

*return HHTP response (loResp.BodyStr) is :

{"_links": { "_update":{"href":"https://z1.net.e-net.sk:8443/api/customer/1870","method":"PUT"}, "self":{"href":"https://z1.net.e-net.sk:8443/api/customer/1870","method":"GET"}, "_delete":{"href":"https://z1.net.e-net.sk:8443/api/customer/1870","method":"DELETE"} } ,"status":"implementation","customer_name":"MariA!n KovA!Ä222","note":null }

but "customer_name":"Marián Kováč222"

SESSIONLOG:

---- Sending ---- GET /api/customer/1870 HTTP/1.1 charset: utf-8 Host: z1.net.e-net.sk:8443 Authorization: Basic YWxmZXVzOmtvbXBsZXg= Content-Length: 1 Content-Type: application/json; charset="utf-8"

---- Received ---- HTTP/1.1 200 OK Date: Thu, 27 Sep 2012 08:13:58 GMT Server: Apache/2.2.9 (Debian) mod_fastcgi/2.4.6 mod_ssl/2.2.9 OpenSSL/0.9.8n Vary: Content-Type Content-Length: 336 Content-Type: application/json

{"_links":{"_update":{"href":"https://z1.net.e-net.sk:8443/api/customer/1870","method":"PUT"},"self":{"href":"https://z1.net.e-net.sk:8443/api/customer/1870","method":"GET"},"_delete":{"href":"https://z1.net.e-net.sk:8443/api/customer/1870","method":"DELETE"}},"status":"implementation","customer_name":"Marián Kováč222","note":null}

asked Sep 27 '12 at 04:10

kofo's gravatar image

kofo
1223

loResp.BodyStr work NOT correct loResp.SaveBodyText work CORRECT

(Sep 27 '12 at 05:04) kofo

Please try to maintain line-endings in your HTTP session logs.

The HTTP response in this case provides no indication of the charset for the bytes composing the body of the response. In other words, the "Content-Type" header of the response does not provide a "charset" attribute that tells a program receiving the response how to interpret the bytes of the body. Should the bytes be interpreted as utf-8? iso-8859-1? iso-8859-2? Etc. When NO charset is specified, the default according to MIME specifications is us-ascii.

The loResp.BodyStr property is a string, and in FoxPro (i.e. in ActiveX), strings are Unicode. Therefore, the bytes of the response body must be interpreted according to a specified character encoding. (See http://www.example-code.com/charset101.asp ) Given that no charset was specified, the default (us-ascii), according to MIME standards, is used. The accented chars ( áč ) have no representation in us-ascii, and therefore they are dropped.

The same problem is not seen with the SaveBodyText method because the bytes of the body are simply saved to the file with no attempt to interpret the bytes as characters.

link

answered Sep 27 '12 at 10:15

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×186

Asked: Sep 27 '12 at 04:10

Seen: 1,008 times

Last updated: Sep 27 '12 at 10:15

powered by OSQA