Response createResponse( final Request request, final RubyArray result )
{
Response r = new Response( request );
if( result.size() != 3 )
{
r.setException( new ServiceException( "bad rack response: " + result.inspect().toString() ) );
return r;
}
IRubyObject body = request.getRuntime().getNil();
try
{
IRubyObject result1 = result.entry( 0 );
if( result.isNil() )
{
r.setException( new ServiceException( "bad rack response, null status code: " + result.inspect().toString() ) );
return r;
}
int codeInt = RubyInteger.num2int( result1 );
if( codeInt < 100 )
{
r.setException( new ServiceException( "bad rack response, status code integer less than 100" ) );
return r;
}
r.setResponseCode( codeInt );
RubyHash headers = result.entry( 1 ).convertToHash();