HTTP library problems

Luis Rodrigues

Member
Licensed User
Longtime User
I've a B4ppc program wich works fine, using http library, with all windows versions until Windows10.
When i try to access my server on Windows10, with " Response.Value = Request.GetResponse", it gives me a "serverprotocolviolation" message.
No problems with 8.1.
 

agraham

Expert
Licensed User
Longtime User
The following works for me accessing Wikipedia under Windows 10 so I guess that Windows 10 may be being a bit more picky about the parsing the response headers from your server.

B4X:
Sub GetText
      Response.New1
      Request.New1( "http://en.wikipedia.org/wiki/HTTP")
      Response.Value = Request.GetResponse
      String = Response.GetString
      Response.Close
      Return String
End Sub

If you can't correct the server response you could try putting the following in a file called "yourprojectname.exe.config" in your project folder

B4X:
<?xml version="1.0"?>
<configuration>
      <system.net>
            <settings>
                  <httpWebRequest useUnsafeHeaderParsing="true"/>
            </settings>
      </system.net>
</configuration>

By the way this is seems to be a known 'problem' with Modern/Metro/Universal apps and some servers that return malformed headers as it is not possible to switch on unsafe header parsing for these sorts of apps.
 

Luis Rodrigues

Member
Licensed User
Longtime User
Thank you for your prompt reply.
As you've recomended the config file solved the problem.
That makes the executable work fine. But what about the interpreted file?
I mean, how can i get the same results while developing?

Thanks again for you kind attention.
 

agraham

Expert
Licensed User
Longtime User
If there isn't already a "Basic4ppc Desktop.exe.config" file in your "ProgramFiles\AnyWhereSoftware\Basic4ppc folder make a copy of the project config file, rename it and put it there.

If there is one then edit it to look like this
B4X:
<?xml version="1.0"?>
<configuration>
      ...
      <system.net>
            <settings>
                  <httpWebRequest useUnsafeHeaderParsing="true"/>
            </settings>
      </system.net>
</configuration>
 

Luis Rodrigues

Member
Licensed User
Longtime User
Thanks Agraham. I've tried that before, but didn't work. I'm going to look again. Maybe i've done something went wrong.
Best regards.
Thank you very much.
 
Top