Thanks Lunasole, your message makes me searched in the right direction and I came with that solution:
Code: Select all
Define response.s = ~"HTTP/1.1 200 OK\r\nCache-Control: no-cache, private\r\nContent-Length: 95\r\nDate: Mon, 24 Nov 2014 10:21:21 GMT\r\nAccess-Control-Allow-Origin: *\r\nConnection: close\r\n\r\n" +
"HERE IS STRING To PRINT IN BROWSER CONSOLE, SET CORRECT Content-Length To A SIZE OF THIS STRING"
\r\n\r\n at the end is important, as well as Access-Control-Allow-Origin. Connection: close is optional though (I assume it's better to close the connection if the client has nothing more to say...).
Date should be properly pre-formatted somewhere.
It's quite fun to manipulate low level requests ; I shoud learn node.JS
Now I just have to figure out how to send parameters to the server (aka understand the $.ajax() function).
EDIT: which is:
Code: Select all
$.ajax("http://localhost:6832", { data: "THIS_IS_DATA_FROM_CLIENT" }).done(function (data) {
console.log(data);
});
And in PB, something like that (messy but it works ^^):
Code: Select all
ReceiveNetworkData(ClientID, *Buffer, 1000)
Define clientRequest.s = PeekS(*Buffer, -1, #PB_UTF8) ; HTTP request header
Define clientData.s = StringField(StringField(clientRequest, 2, "/?"), 1, " ")
MessageRequester("Client data", clientData) ; parameters from client
SendNetworkString(ClientID, response) ; parameters to client (response)