Issue posting with xojo.Net.HTTPSocket on Windows

Has anyone experienced issues doing “POST” requests with xojo.Net.HTTPSocket on Windows?

It seems that the post variables never arrives at the server. Here is the code I use to peform the post (copied from the Xojo documentation examples).

  Using Xojo.Core
  
  ' Build form text
  Dim formText As Text = "firstName=Bob&lastName=Roberts"
  
  ' Convert to MemoryBlock
  Dim postData As Xojo.Core.MemoryBlock
  postData = Xojo.Core.TextEncoding.UTF8.ConvertTextToData(formText)
  
  ' POST it
  
  mySocket.SetRequestContent(postData, "application/x-www-form-urlencoded")
  mySocket.Send("POST", "http://localhost/zms")

It is posting to a PHP website. When I echo the $_POST variable it shows that there are no post variables in the request? I’m using Xojo 2015 Release 2.4 for this project.

Posting to the same website with the classic HTTPSocket works perfectly without error.

Any information or advice would be greatly appreciated, for this issue is a showstopper preventing me from fully migrating to the new framework.

Out of curiousity have you tried a newer IDE to see if the issue was fixed?

Actually busy downloading the latest IDE to do just that.

Just tested the example using Xojo 2016 Release 4.1… same problem.

POST variables are missing on the server side?

That’s interesting. I’ve got a project that I’m working on here which posts just fine using code that looks like this:

Dim Data as Xojo.Core.Memoryblock = Xojo.Core.TextEncoding.UTF8.ConvertTextToData(js.toString.ToText) h.SetRequestContent(Data, "application/json") h.Send("POST",url)

It may just be that particular content encoding that’s having trouble.

RapidServers (http://www.dev.1701software.com/rapid-services-for-xojo-web/encrypted-edition) is built on Xojo.Net.HTTPSocket for all platforms and uses POST 99% of the time and it works fine.

Thanks guys.

It then must be something on my side. I’ll investigate further and give an update once I have more information.

UPDATE:
I found the problem.

I seems that I need to specify the full URL with the new HTTPSocket:

  mySocket.Send("POST", "http://localhost/zms/index.php")

while the following worked in the classic framework:

  mySocket.Send("POST", "http://localhost/zms")

Maybe this is a HTTP 1.0 vs HTTP 1.1 thing?

Anyways… this is great news. Now I can move forward with the migration to new framework :slight_smile:

[quote=319949:@Alwyn Bester]UPDATE:
I found the problem.

I seems that I need to specify the full URL with the new HTTPSocket:

  mySocket.Send("POST", "http://localhost/zms/index.php")

while the following worked in the classic framework:

  mySocket.Send("POST", "http://localhost/zms")

Maybe this is a HTTP 1.0 vs HTTP 1.1 thing?

Anyways… this is great news. Now I can move forward with the migration to new framework :)[/quote]

That’s strange. I have no idea why the server’s index feature wouldn’t work.

Yeah, I’m also wondering why it behaved the way it did.

And the strangest thing is that it does exactly the same on my local WAMP development installation, as well as my live production server (two completely different configurations and environments). And it also does this on my home pc, as well as my work pc.

Been a real struggle to get to the bottom of it. But at least I can now carry on with the migration.

I think I found out why the full URI was required… proxy servers.

The following information in RFC2616 for HTTP 1.1 leads me to believe proxies to be the problem:

Although this would not explain why the issue occurs on my local WAMP server.

What are you using for the local WAMP server?

(W) Windows 7
(A) Apache v2.4.9
(M) MySQL v5.6.17
§ PHP v5.5.12

Everything works as long as I specify the full URI, so at least I can upgrade all my client side apps to use the new Xojo.Net.HTTPSocket socket, and take advantage of HTTP 1.1.

Will let you guys know if I do discover with certainty why the full URI was required for POST requests.

Interestingly, all the GET requests worked without having to specifying the full URI.