I'm trying to send data from my Gear S to my laptop via wifi. I run a simple java socket server on my laptop
that prints what it receives and sends a HTML message back. Everything works just fine when I test my server
with an extension of Google Chrome called "Advanced Rest Client". But when I try to send something from my
Gear S, it appears the actually message itself isn't included. The weird thing is that the content-length field is
correct. The code of my web application is:
function buttonsendclicked() { console.log("Button Clicked"); var client = new XMLHttpRequest(); client.open("post", "http://192.168.0.226:8080"); client.setRequestHeader("Content-Type", "application/text/plain"); client.onreadystatechange = function() { if (client.readyState == 4 && client.status == 200) { alert(client.status); } } client.send("Send data"); console.log("test"); }
I get the following output when I receive this message on my server:
POST / HTTP/1.1
Host: 192.168.0.226:8080
User-Agent: Mozilla/5.0 (Linux; Tizen 2.2.1.4; SAMSUNG SM-R750) AppleWebKit/538.1 (KHTML, like Gecko) Version/2.2.1.4 Mobile Safari/538.1
Origin: file://
Content-Type: application/text
Accept: */*
Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1
Accept-Encoding: gzip, deflate
Accept-Language: en-GB
Connection: Keep-Alive
Content-Length: 9
And normally the text appears under "Content-Length: 9". What am I forgetting/doing wrong?