iOS Question ResponseError: unsupported URL, status code: 0

marconotsopolo

Member
Licensed User
I am having a little difficulty with the post strings using iHtppUtils going to my jRDC server. If I leave the iOS post string unencoded the app throws out the error ResponseError: unsupported URL, however if I encode it using stringutils, the app sends the post but the jRDC server handler cannot read the method statement. This works perfectly fine in the B4A app using the same httputils2 library. I have read that the library already encodes the string, but for iOS this doesn't seem to like it, so I have to encode it with stringutils and then it goes.

My formatted string looks like (B4A & B4i)

If I encoded the B4i string then formatted string looks like this

And the jRDC cannot pull out the getparameter("method") statement from this correctly. (Dim method as string = req.GetParameter("method"))

I am sorry if this seems a little vague and happy to send on any other info to help diagnose this issue.

 

marconotsopolo

Member
Licensed User
I don't understand anything from your question.

1. You are asking about POST request and sending GET parameters.
2. Your question has nothing to do with jRDC2.
My apologies, I am doing the best I can to try to explain my problem. I am not a developer so my interpretations or explanations may not be as technical as you may need them.

I will try again. So I have a B4XPages program that sends a POST request to my server (which is running the jRDC server program), in the B4A code the request completes on the server without an issue and a response received, however in the B4i code the POST request does not complete on the server and the reason from what I can see is that the POST request is encoded with "%" where as the server received string from the B4A app does not.

Is this any clearer?.
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
My apologies, I am doing the best I can to try to explain my problem. I am not a developer so my interpretations or explanations may not be as technical as you may need them.

I will try again. So I have a B4XPages program that sends a POST request to my server (which is running the jRDC server program), in the B4A code the request completes on the server without an issue and a response received, however in the B4i code the POST request does not complete on the server and the reason from what I can see is that the POST request is encoded with "%" where as the server received string from the B4A app does not.

Is this any clearer?.

Try in the B4J back end or any back end you use, to change %20 with the plus symbol ('+')... Also make it clear to the backend that the request is from B4i by adding an other querystring variable (f.e. &src=b4i) in order to make this replacement...
 
Upvote 0

hatzisn

Expert
Licensed User
Longtime User
Try in the B4J back end or any back end you use, to change %20 with the plus symbol ('+')... Also make it clear to the backend that the request is from B4i by adding an other querystring variable (f.e. &src=b4i) in order to make this replacement...

Also encode the variables, not the entire querystring in b4i...
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Also encode the variables, not the entire querystring in b4i...
That's correct.

This is the code in HttpJob that escapes the parameters (it is called from Job.Download2):
B4X:
Private Sub escapeLink(Link As String, Parameters() As String) As String
    Dim sb As StringBuilder
    sb.Initialize
    sb.Append(Link)
    If Parameters.Length > 0 Then sb.Append("?")
    Dim su As StringUtils
    For i = 0 To Parameters.Length - 1 Step 2
        If i > 0 Then sb.Append("&")
        sb.Append(su.EncodeUrl(Parameters(i), "UTF8")).Append("=")
        sb.Append(su.EncodeUrl(Parameters(i + 1), "UTF8"))
    Next
    Return sb.ToString
End Sub

It only escapes the keys and values. Not the equal sign.
 
Upvote 0

marconotsopolo

Member
Licensed User
That's correct.

This is the code in HttpJob that escapes the parameters (it is called from Job.Download2):
B4X:
Private Sub escapeLink(Link As String, Parameters() As String) As String
    Dim sb As StringBuilder
    sb.Initialize
    sb.Append(Link)
    If Parameters.Length > 0 Then sb.Append("?")
    Dim su As StringUtils
    For i = 0 To Parameters.Length - 1 Step 2
        If i > 0 Then sb.Append("&")
        sb.Append(su.EncodeUrl(Parameters(i), "UTF8")).Append("=")
        sb.Append(su.EncodeUrl(Parameters(i + 1), "UTF8"))
    Next
    Return sb.ToString
End Sub

It only escapes the keys and values. Not the equal sign.
Ah OK that makes sense, thank you both.
 
Upvote 0
Top