I'm working on a proxy-kind thing, which should make a request via NSURLSession and progressively transfer it to the GCDWebServer response.
The issue is with GCDWebServerStreamedResponse responseWithContentType:asyncStreamBlock
– it requires a content type, so must be called after I got a headers. And it returns a completion block asynchronously for some reason, while the data could be received faster.
I mean, now it works this way:
- API makes a call to GCDWebServer
- GCDWebServer creates a NSURLSession data task
- data task receive headers
- create GCDWebServerStreamedResponse
- receive data chunk (which I want to push into the streamed response)
- got the completion block from step 4
How can I get the completion block right after step 4?
Sorry if I've missed any info, just I'm stuck with it and almost sure I'm doing something wrong way...