I have used Erel's modified code to get the http response header. I need to get the 3 keys from the response header and use those keys at the next request. The returned header is like this ( it is returned as httpjob's tag). How can I get the CloudFront-Signature,CloudFront-Key-Pair-Id and CloudFront-Policy keys from these text ?
Where is your code? Do not expect everyone know which code you exactly did changed or used.
Also note that the okhttputils does provide a Resultobject with the headers. Did you checked them?
B4X:
Sub JobDone(Job As HttpJob)
HideKeyboard
ProgressDialogHide
If Job.Success Then
Dim resp As OkHttpResponse = Job.Response
Dim headers As Map = resp.GetHeaders
For Each key As String In headers.Keys
Log($"Header: ${key} = ${headers.Get(key)}"$)
Next
What have you tried? What didn't work?
Those keys you mention are in the text, so you only need to extract them, you can use different methods to do so. Regex being the hardest (imho) and simple string splitting being the most straight forward.
In fact, what I meant was as DonManfred stated, is there a resultobject but as you say, it is a simple text, and what DonManfred suggested works perfect here. I couldn't extract it from the text.
What have you tried? What didn't work?
Those keys you mention are in the text, so you only need to extract them, you can use different methods to do so. Regex being the hardest (imho) and simple string splitting being the most straight forward.
Where is your code? Do not expect everyone know which code you exactly did changed or used.
Also note that the okhttputils does provide a Resultobject with the headers. Did you checked them?
B4X:
Sub JobDone(Job As HttpJob)
HideKeyboard
ProgressDialogHide
If Job.Success Then
Dim resp As OkHttpResponse = Job.Response
Dim headers As Map = resp.GetHeaders
For Each key As String In headers.Keys
Log($"Header: ${key} = ${headers.Get(key)}"$)
Next
I said working well and it is but problem now is I get the headers' keys and it is like this: The things I need is in a single key so Should I use text splitting or regex to get those, I think there is no other way to get it.
B4X:
Waiting for debugger to connect...
Program started.
Header: content-length = [15558]
Header: content-type = [application/json; charset=utf-8]
Header: date = [Fri, 03 May 2019 10:34:06 GMT]
Header: set-cookie = [CloudFront-Signature=PxOhQCxfhCVNfAr72SRETyTy72BGAdr4yT5jHhj8v4dSzsb4au0eDVfvyQVx15Ml4sjjvLim~lgsW3wQu3~4PxFTMqiA-jV8e144oy37r~j1y1zRMz4anKMpTG6TybS65IkO4rXdVK1Fok3mhy8Y~-b5QgyiUE3LUIHzv3XaTHHRLKBlTLWDk2GscKGPhhM6wtOZ8SnThnqaMfgtSjG9slepk9DnqLV7WRDcrAGnkJ-~K-NLx2lBb7BzzUEG1c0ii49CDhB5FcdF1vh9LiaaydJhwMrebzwGyM-uqu4UlOdfSnW~2HD7RjNT9z6l1h4QSZOt2rq~H3SgX3t8yGMzdg__; Path=/; Domain=.xxx.com; Secure; HTTPOnly, CloudFront-Key-Pair-Id=APKAIVVJE7R23ILHVNCQ; Path=/; Domain=.xxx.com; Secure; HTTPOnly, CloudFront-Policy=eyJTdGF0ZW1lbnQiOiBbeyJSZXNvdXJjZSI6Imh0dHBzOi8vbmV3cy1jb250ZW50LmZvcmVrcy5jb20vKiIsIkNvbmRpdGlvbiI6eyJEYXRlTGVzc1RoYW4iOnsiQVdTOkVwb2NoVGltZSI6MTU1Njg4MzI0Nn19fV19; Path=/; Domain=.xxx.com; Secure; HTTPOnly]
try to get the header set-cookie from the map. Try to cast it to a map instead of a string.
Note that the Cookies are a List.
1. get headers
2. get the list set-cookie from the headermap.
3. iterate through the List. Maybe the items in the list are MAPS. You need to try
At least you should now have a string which you could parse using regex....
try to get the header set-cookie from the map. Try to cast it to a map instead of a string.
Note that the Cookies are a List.
1. get headers
2. get the list set-cookie from the headermap.
3. iterate through the map. Maybe the items in the list are MAPS. You need to try
At least you should now have a string which you could parse using regex....