public
Created — forked from macton/test_http.js

Examples of using jsdb http_utils.js Stream.GET and Stream.POST extensions

  • Download Gist
test_http.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
load('http_utils.js');
 
writeln('-------- Example 0 ---------');
 
var search_topic = 'dancing cats';
var google_api = new Stream('net://ajax.googleapis.com:80');
 
function show_result( data )
{
writeln('Google found ' + data.responseData.cursor.resultCount + ' pages about ' + search_topic );
}
 
google_api.GET( '/ajax/services/search/web', { v: '1.0', q: search_topic }, show_result, 'json' );
google_api.close();
 
writeln('-------- Example 1 ---------');
 
var posttestserver = new Stream('net://posttestserver.com:80');
var get_test = posttestserver.GET('/data/2010/10/17/18.40.351320933049');
var post_test = posttestserver.POST('/post.php', { sample_text : 'hello, world!', sample_array: [ 0, 1, 2, 3, 4 ] } );
 
writeln( get_test );
writeln( post_test );
 
posttestserver.close();

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.