fix for 'TypeError: Object #<ServerResponse> has no method 'type' error'