JSORB

 view release on metacpan or  search on metacpan

example/js/jquery-1.2.6.js  view on Meta::CPAN

			var xhrRes = xhr.getResponseHeader("Last-Modified");

			// Firefox always returns 200. check Last-Modified date
			return xhr.status == 304 || xhrRes == jQuery.lastModified[url] ||
				jQuery.browser.safari && xhr.status == undefined;
		} catch(e){}
		return false;
	},

	httpData: function( xhr, type, filter ) {
		var ct = xhr.getResponseHeader("content-type"),
			xml = type == "xml" || !type && ct && ct.indexOf("xml") >= 0,
			data = xml ? xhr.responseXML : xhr.responseText;

		if ( xml && data.documentElement.tagName == "parsererror" )
			throw "parsererror";
			
		// Allow a pre-filtering function to sanitize the response
		if( filter )
			data = filter( data, type );

t/300_catalyst_action.t  view on Meta::CPAN


use Catalyst::Test 'TestApp';

{
    my $request = HTTP::Request->new( 
        GET => 'http://localhost:3000/rpc?method=/test/app/greeting&params=[]' 
    );

    ok(my $response = request($request), '... got a response from the request');
    ok($response->is_success, '... response is successful');
    is($response->header( 'Content-Type' ), 'application/json-rpc', '... got the JSON content-type');    
    is($response->code, 200, '.. response code is 200');
       
    is($response->content, '{"jsonrpc":"2.0","result":"Hello World"}', '... got the content we expected');
}


{
    my $request = HTTP::Request->new( 
        GET => 'http://localhost:3000/foo/rpc?method=/test/app/greeting&params=["Man"]' 
    );

    ok(my $response = request($request), '... got a response from the request');
    ok($response->is_success, '... response is successful');
    is($response->header( 'Content-Type' ), 'application/json-rpc', '... got the JSON content-type');    
    is($response->code, 200, '.. response code is 200');
       
    is($response->content, '{"jsonrpc":"2.0","result":"Yo! What\'s up Man"}', '... got the content we expected');
}

{
    my $request = HTTP::Request->new( 
        GET => 'http://localhost:3000/foo/rpc?method=/test/app/greeting&params=["Man"]&greeting_prefix=Hey!' 
    );

    ok(my $response = request($request), '... got a response from the request');
    ok($response->is_success, '... response is successful');
    is($response->header( 'Content-Type' ), 'application/json-rpc', '... got the JSON content-type');    
    is($response->code, 200, '.. response code is 200');
       
    is($response->content, '{"jsonrpc":"2.0","result":"Hey! What\'s up Man"}', '... got the content we expected');
}

foreach my $i (1 .. 3) {
    my $request = HTTP::Request->new( 
        GET => 'http://localhost:3000/foo/rpc?method=/test/app/foo/bar&params=[]' 
    );

    ok(my $response = request($request), '... got a response from the request');
    ok($response->is_success, '... response is successful');
    is($response->header( 'Content-Type' ), 'application/json-rpc', '... got the JSON content-type');    
    is($response->code, 200, '.. response code is 200');
       
    is($response->content, '{"jsonrpc":"2.0","result":"FOO::BAR(' . $i . ')"}', '... got the content we expected');
}



( run in 0.540 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )