Java Question HttpURLConnection

Shay

Well-Known Member
Licensed User
Longtime User
Hi

is this libary exist in b4a?
HttpURLConnection | Android Developers

I need to use:
Secure Communication with HTTPS
Calling openConnection() on a URL with the "https" scheme will return an HttpsURLConnection.
This class attempts to create secure connections using common TLS extensions and SSL deflate compression. Should that fail, the connection will be retried with SSL3 only.


Thanks
Shay
 

Shay

Well-Known Member
Licensed User
Longtime User
Erel,

I am using the following example, and I can see in tcpdump (wireshark)
that it is using https TLS1, but the compression (deflate) is null (not working)
any suggestion?

see packet number 4 (b4a.pcap), under "commpression method" it is null - it should be deflate
(see good_pcap - from real browser)



'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.

Dim hc As HttpClient

Dim URL As String
URL = "https://10.1.11.146"

End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

Dim Button1 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)

activity.LoadLayout ("main")

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Open_URL

Dim req As HttpRequest
hc.InitializeAcceptAll("hc")
req.InitializeGet(URL)
hc.Execute(req, 1)

End Sub

Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
Dim resultString As String
Result = Response.GetString("UTF8")
'Work with the result
End Sub

Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Log("Error connecting: " & Reason & " " & StatusCode)
If Response <> Null Then
Log(Response.GetString("UTF8"))
Response.Release
End If
End Sub

Sub Button1_Click
Open_URL
End Sub
 

Attachments

  • ssl_deflate.zip
    5.3 KB · Views: 319

Shay

Well-Known Member
Licensed User
Longtime User
no error,
the ssl deflate is not working
(see attachment)
also see how it should be in the pcap I send before
 

Attachments

  • null.JPG
    null.JPG
    23 KB · Views: 335

Shay

Well-Known Member
Licensed User
Longtime User
this is how it should be (from client prespective)
 

Attachments

  • deflate.JPG
    deflate.JPG
    31.5 KB · Views: 345

Shay

Well-Known Member
Licensed User
Longtime User
using chorme and andriod to the same https server
with chorme it is working fine, and with andriod not
 
Top