I have made a Drupal module with a single page to display only json data like this :
drupal_add_http_header('Status', $code);
drupal_json_output($data);
$Code
can be 200, 204, 401, 404 etc.
When my page is called by Postman it's ok.
When my page is called by Java application it's return -1.
I got the full stack trace and I uploaded it on pastebin : http://pastebin.com/PvCeQuU5
Any idea ?
I set my hook_menu like this :
$items['mymodule/json'] = array(
'title' => t('Page title'),
'page callback' => array('mymodule_pagejson'),
'access callback' => TRUE,
'type' => MENU_NORMAL_ITEM,
'delivery callback' => 'drupal_json_output',
);
return $items;
The problem is that the delivery callback with drupal_json_output() returns 4 characters even if it's a 204 status.
But 204 status doesn't allow a Content-Lenght more then 0 (as it's said in the RFC) thus the html data layer of java broke down.
Postman shows that Content-Lenght is more then 0 but allows the query to be executed normally.