<!--
Thanks for opening an issue! A few things to keep in mind:

- The issue tracker is only for bugs and feature requests.
- Before reporting a bug, please try reproducing your issue against
  the latest version of Electron.
- If you need general advice, join our Slack: http://atom-slack.herokuapp.com
-->

@deepak1556 This is the issue I mentioned on Slack, thanks for your help!

* Electron version: v1.6.6
* Operating system: OSX 10.12.4

### Expected behavior

Service worker scripts should successfully load after defining a custom protocol interception on `file`. 

### Actual behavior

After defining an intercept function on `file` protocol by calling `interceptBufferProtocol`, service worker scripts fail to load with the error:

```
error when registering service worker TypeError: Failed to register a ServiceWorker: A bad HTTP response code (-1) was received when fetching the script. 
```

This occurs after a call to `interceptBufferProtocol` in the `electron-compile` npm package (in `lib/protocol-hook.js`. If this call is taken out or `protocol.uninterceptProtocol('file');` is called afterward, service worker scripts load correctly.

### How to reproduce

```
git clone https://github.com/concreted/esw -b test_electron_compile
npm install
electron .
```

You should see the `error when registering...` error in the browser window console.
<!-- 

Your best chance of getting this bug looked at quickly is to provide a REPOSITORY that can be cloned and run.

You can fork https://github.com/electron/electron-quick-start and include a link to the branch with your changes.

If you provide a URL, please list the commands required to clone/setup/run your repo e.g.

  $ git clone $YOUR_URL -b $BRANCH
  $ npm install
  $ npm start || electron .

-->

atom/browser/net/url_request_buffer_job.cc
std::string status("HTTP/1.1 ");
  status.append(base::IntToString(status_code_));
  status.append(" ");
  status.append(net::GetHttpReasonPhrase(status_code_));
  status.append("\0\0", 2);
  auto* headers = new net::HttpResponseHeaders(status);
  headers->AddHeader(kCORSHeader);
  if (!mime_type_.empty()) {
    std::string content_type_header(net::HttpRequestHeaders::kContentType);
    content_type_header.append(": ");
    content_type_header.append(mime_type_);
    headers->AddHeader(content_type_header);
  }
  info->headers = headers;
}
int URLRequestBufferJob::GetRefCountedData(
    std::string* mime_type,
    std::string* charset,
    scoped_refptr<base::RefCountedMemory>* data,
    const net::CompletionCallback& callback) const {
  *mime_type = mime_type_;
  *charset = charset_;
  *data = data_;
  return net::OK;
}
}