gcdwebserver

GCDWebServerFileResponse, knowing when file is no longer being used


I'm using GCDWebServer in a sandboxed MacOS desktop application.

I make a file available to a client using the GCDWebServerFileResponse, which works well.

However, some of the file resources are accessed via a Security Scoped Bookmark (because of the sandbox).

Before accessing the file I need to call bookmarkURL.startAccessingSecurityScopedResource() and then once I finish using the file I need to balance it with a bookmarkURL.stopAccessingSecurityScopedResource().

The issue I have is that I don't currently know when the web server has finished the response and the file is free to to close off.

Are there any listeners I can attach, or keys I can observe?

Thanks


Solution

  • Easiest way is likely to subclass GCDWebServerFileResponse and override -close. See docs in GCDWebServerResponse.h.