Android Question PostString with HttpUtils2, every Ascii -value?

Discussion in 'Android Questions' started by skrjabin, Jul 15, 2015.

  1. skrjabin

    skrjabin Member Licensed User

    I am posting a request as a string to my server:

    Sub CallSyncServ(request As String)
    Dim jobSync As HttpJob
    jobSync.Initialize("JobSyncServ", Me)
    Dim sServer As String = "http://myserver/mypage.aspx"
    jobSync.PostString(sServer, request)
    End Sub

    In my Tests some chars in the request-string are changed on the server. So the '=' (Ascii 61) becomes a Ascii 17 or 18
    Can I use every Byte in the string for transfer? Do I have to escape some Bytes? What can I do, that the '=' stays a '=' on the server?
  2. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Could it help to urlEncode the string ?
  3. skrjabin

    skrjabin Member Licensed User

    Thanks for your answer.
    I hope this is not necessary, because the string is transfered via POST and is not an URL.
    I have to use my own data-format, with delimeters Ascii 17 and 18 between the data-sets and I was so glad, that in my tests every byte seems to be allowed with the transfer.
    So URL-Encoding is not the right choice. If it is only the '=' I could escape that, but I first want to find out here what is the best way.
  4. Erel

    Erel Administrator Staff Member Licensed User

    You do not need to url encode POST payload.

    Your server treats the request content type as: application/x-www-form-urlencoded
    This format is similar to GET parameters which are separated with =

    How are you reading the request data on the server?
  5. skrjabin

    skrjabin Member Licensed User

    So I read the request on the

    Dim sData As String = Request.Form(0) 'complete Request-String
    Dim sDS() As String = Split(sData, Sep2) 'Array of all Rows

    Every byte is recieved ok, even the ascii 17 and 18, which is usesd as seperator-Byte. For now only the '=' makes problemes. In Details: The string is splittet in to an array with the seperator-Byte. But '=' also will split the string. This is the problem.
  6. Erel

    Erel Administrator Staff Member Licensed User

    Set the request content type (in B4A) to text/plain
  7. skrjabin

    skrjabin Member Licensed User

    Thanks, I will check it in the next days and than give my feedback.
  8. skrjabin

    skrjabin Member Licensed User

    Yes, this seems to work:
    jobSync.PostString(sServer, request)
    But on server-side (in VB.NET or C#) instead of Request.Form(0) you should use Request.InputStream to copy the complete request to a string.

    For me it is not clear, how it is possible to define the header as text/plain after sending the body, but it works :)
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice