Android Question java.net.ProtocolException: Unexpected status line:

Discussion in 'Android Questions' started by Alberto Michelis, Jul 18, 2019.

  1. Alberto Michelis

    Alberto Michelis Active Member Licensed User

    B4A 8.8
    Using OkHttpUtils2
    Fetching a web page that is fetched ok with b4a older versions, Im getting the following error.

    !!! java.net.ProtocolException: Unexpected status line: <!DOCTYPE html>

    I can access the page using Firefox browser

    http://132.148.84.1:8633/xmloc?F=Lanz&E=O-25-5-20

    The result is a simple xml

    What is a status line? what should I add to the page to get rid of this error?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    The http response is invalid. It should start with the status line (ex: Http/1.1 200 OK).

    You can use Socket with AsyncStreams to read it.
     
  3. Alberto Michelis

    Alberto Michelis Active Member Licensed User

    I cant use Sockets
    You mean first line of the response must be:
    <Http/1.1 200 OK> ?
    or how to add Http/1.1 200 OK to the response?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Why not?

    Is this your server?
     
  5. Alberto Michelis

    Alberto Michelis Active Member Licensed User

    Yes it is but is a server made in Clarion and does not supports sockets.
    Ive added Http/1.1 200 OK in the first line of the page and now Im getting another error:

    ResponseError. Reason: java.io.IOException: unexpected end of stream on okhttp3.Address@4068ce87, Response:
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    There must be an empty line after the headers and before the body.
    Make sure to use CR & LF as the end of line characters.
     
Loading...
  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