Once #3032124: delivery callback not found is resolved according to hook_menu() docs pwa_deliver_js_file() should handle menu status codes in a similar way to drupal_deliver_html_page().

e.g.

/**
 * Deliver the JS for the service worker.
 *
 * Adds a Service-Worker-Allowed header so that a file served from
 * '/pwa/serviceworker/js' can have a scope of '/'.
 */
function pwa_deliver_js_file($page_callback_result) {
  drupal_add_http_header('Content-Type', 'application/javascript');
  drupal_add_http_header('Content-Disposition', 'inline; filename="serviceworker.js"');
  drupal_add_http_header('Service-Worker-Allowed', base_path());
  
  if (is_int($page_callback_result)) {
    switch ($page_callback_result) {
      case MENU_NOT_FOUND:
        drupal_add_http_header('Status', '404 Not Found');
        break;
      case MENU_ACCESS_DENIED:
        drupal_add_http_header('Status', '403 Forbidden');
        break;
      case MENU_SITE_OFFLINE:
        drupal_add_http_header('Status', '503 Service unavailable');
        break;
    }
  }
  elseif (isset($page_callback_result)) {
    print $page_callback_result;
  }
}

Comments

MustangGB created an issue. See original summary.

nod_’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Postponed » Fixed

done in 7.x-2.x

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.