Reputation: 67
I have ICAP server which is scanning files and ICAP client running pyicap library (https://github.com/netom/pyicap)
I want to allow users to start downloading files via ICAP client but hold last couple of bytes while there is no response from ICAP server.
If ICAP will allow request, python ICAP client will release last bytes and user will get a file. But if ICAP will denies this request, last chunks must not be released and ICAP client must send cancel or abort to the client.
i have chunks of file
chunk_size = 4096 if file_size > 4096 else file_size / 2
# slice file into two chunks or lots of chunks
chunks = 2 if file_size / chunk_size < 1 else file_size / chunk_size
self.send_headers(True)
while chunks > 1:
data = upstream.read(chunk_size)
if not data:
print("no more data")
break
self.write_chunk(data)
chunks -= 1
If ICAP allows ths request, i can send the last chunk and everything OK but if it's denies i have no idea how to abort download of this file by the client.
How to send cancel or abort to the client?
Upvotes: 1
Views: 494