WWW using CONNECT instead of POST?

Hi,

I’m using WWW to call a RESTful api (azure table storage) but I when I attempt to POST to the server Fiddler shows that CONNECT is being used and the url is slightly wrong.

I’m using the following:

public static WWW PostDataOnServer(string url, byte[] data, Dictionary<string, string> headers)
		{
			Debug.Log("Posting data to: " + url);
			return new WWW(url, data, headers);
		}

Where the url= https://myAccount.table.core.windows.net/Tables
The byte data is a UTF8 encoded version of the following string:

"{
	"TableName":"TableTest"
}"

And I’m using the following headers: Date, x-ms-version, Content-Type, Content-Length, Authorization.

Fiddler shows that WWW is sending the following:

CONNECT myAccount.table.core.windows.net:443 HTTP/1.1
Host: myAccount.table.core.windows.net:443
User-Agent: UnityPlayer/4.3.4f1 (http://unity3d.com)
Proxy-Connection: Keep-Alive
Authorization: SharedKeyLite myAccount:mysharedKey=
Content-Length: 28
Content-Type: application/json
Date: Mon, 17 Feb 2014 11:40:31 GMT
x-ms-version: 2013-08-15

That first line should be reading as:

POST https://myAccount.table.core.windows.net/Tables HTTP/1.1

The host address shouldn’t be showing port 433 either. I’ve double checked that the correct address is going in (you’ll see the Debug.Log in the method which prints out the correct url as it goes into the new WWW).

Using GET (by not including data in when creating the WWW) works fine and doesn’t alter the url or insert an incorrect verb.

Any ideas why it’s not calling the POST verb and why my url is being altered by WWW?

Best Regards
Hobsie

Maybe you should use WWWForm for POST requests? If I remember correctly WWW class makes GET requests.

Thanks for responding.

According to this: Unity - Scripting API: WWW.WWW

WWW uses GET by default and POST when you give it something for postData.

WWWForm is for setting up Form data to give to WWW (WWWForm isn’t actually used to send HTTP requests).

Really scratching my head over this.

Regards
Hobsie

Lol ok this is great.

It turns out that my using Fiddler to intercept the WWW call has some sort of affect on the call (seems fine for GET). I just tried this again with Fiddler turned off and it return OK and created the table as expected!

So I guess the question now is why did Fiddler cause the call to change? (a question that might not be within the remit of this forum).