guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] read-response-body should return received data when any break ha


From: Nala Ginrut
Subject: [PATCH] read-response-body should return received data when any break happens
Date: Sun, 11 Mar 2012 23:35:56 +0800

I've been troubled with a weird problem in read-response-body for a long time.
I think read-response-body never return the received data when any break happens. No matter the break caused by connection problem or user interruption.
The only possible read-response-body returns data is connection never down and all the data have been received even if I want to download a 2G file. Or there's no
chance to write any data to the disk. When break occurs, all the received data will evaporate.
Considering my terrible network, I decide not to pray for good luck when I establish connection with our web module.
So here's a patch to fix it.

The new read-response-body will add the received data to the exceptional information which used by "throw", if read-response-body can't continue to work anymore, the received data will return with throw.
And there's a useful helper function to write this data to the disk ==> (output-received-response-body e port)

However, add received data to the exceptions will cause troubles when tracing or REPL throw exceptional information, because received data(as a bytevector) is usually huge. So there's another helper function to get rid of the received data after you handle the received data in your way. It will re-throw the original information in case other program need to catch it. ==> (throw-from-response-body-break e)

It's easy to use them, but you must catch anything when your code contains read-response-body:
----------------------------cut-------------------------
(catch #t
          (lambda ()
             .....do some work with read-response-body...)
           (lambda e
                 (output-received-response-body e port) ;; write received-data to the disk or you may decide to store it to other place.
                 ...
                 ...
                 (throw-from-response-body-break e))) ;; re-throw the original information in the last step.
---------------------------end---------------------------

Anyway, one may use it in his/her own way if he/she checkout their implementation. The helper functions are not always necessary.
But I do think read-response-body should return the received data when it breaks.

Any comments?

Regards.

Attachment: 0001-read-response-body-should-return-received-data-in-an.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]