Created
June 1, 2010 05:00
-
-
Save robotarmy/420585 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"POST" | |
{"href":"/","pathname":"/"} | |
{"host":"ledger.robotarmyma.de:7001","user-agent":"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3","accept":"text/javascript, application/javascript, */*","accept-language":"en-us,en;q=0.5","accept-encoding":"gzip,deflate","accept-charset":"ISO-8859-1,utf-8;q=0.7,*;q=0.7","keep-alive":"115","connection":"keep-alive","content-type":"application/x-www-form-urlencoded; charset=UTF-8","referer":"http://ledger.robotarmyma.de:3000/public/test/index.html","content-length":"91","origin":"http://ledger.robotarmyma.de:3000","pragma":"no-cache","cache-control":"no-cache"} | |
";jsonp1275368382519({\"pony\":\"cake\",\"name\":\"biscuit\"});" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Response Headersview source | |
Content-Length 54 | |
Content-Type application/json;charset=uft-8 | |
Connection like a leaf on the wind | |
Request Headersview source | |
Host ledger.robotarmyma.de:7001 | |
User-Agent Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 | |
Accept text/javascript, application/javascript, */* | |
Accept-Language en-us,en;q=0.5 | |
Accept-Encoding gzip,deflate | |
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7 | |
Keep-Alive 115 | |
Connection keep-alive | |
Content-Type application/x-www-form-urlencoded; charset=UTF-8 | |
Referer http://ledger.robotarmyma.de:3000/public/test/index.html | |
Content-Length 91 | |
Origin http://ledger.robotarmyma.de:3000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parametersapplication/x-www-form-urlencoded | |
JSON {"pony":"cake","name":"biscuit"} | |
callback jsonp1275368382519 | |
Source | |
JSON=%7B%22pony%22%3A%22cake%22%2C%22name%22%3A%22biscuit%22%7D&callback=jsonp1275368382519 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module("LedgerService"); | |
$.ajaxSetup({ | |
url: 'http://ledger.robotarmyma.de:7001', | |
}); | |
var item = {pony :'cake', name : 'biscuit'}; | |
asyncTest("POST one with jsonp", 2, function(){ | |
$.ajax({ | |
type:'POST', | |
data: {JSON:JSON.stringify(item) }, | |
dataType:'jsonp', | |
success: function(data,status,xhr) { | |
ok(status =='success', "status -" +status); | |
ok(true,"Cross Domain Access-Control-Allow-Origin"); | |
ok(data != null,"Post Returned Something"); | |
}, | |
error:function() { | |
ok(true); | |
ok(false,"error - on post"); | |
}, | |
complete:function(xhr,status) { | |
start(); | |
} | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LedgerService.prototype.POST = function(request,response,data) { | |
var uri = url.parse(request.url,true) | |
RH(request) | |
out = ";"+data['callback']+"("+data['JSON']+");"; | |
PJ(out); | |
response.writeHead(200, 'from one post to another - walking the way',{ | |
'Content-Length': out.length, | |
'Content-Type': 'application/json;charset=uft-8', | |
'Connection' : 'like a leaf on the wind' | |
}); | |
response.write(out,'utf8'); | |
response.end(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LedgerService.prototype.service = function() { | |
var self = this; | |
var http = require('http'), | |
sys = require('sys'); | |
self.server = http.createServer(); | |
self.server.addListener('request',function(request,response) { | |
var data = ""; | |
var method = request.method; | |
PJ(method); | |
request.setEncoding('UTF8'); | |
request.addListener('data',function(chunk) { | |
data += chunk; | |
}); | |
request.addListener('end',function() { | |
var json = querystring.parse(data); | |
self[method](request,response,json); | |
}); | |
}); | |
self.server.addListener('close',function(errno) { | |
sys.puts('close ' + errno); | |
}); | |
self.server.listen(7001); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment