| Author |
Message |
|
| Guest |
Posted: Tue Sep 05, 2006 11:56 pm |
|
|
|
Guest
|
The yaws_zlib:deflate() function makes use of the OTP zlib:deflate()
function. Unfortunately the API for zlib:deflate() changed between OTP
R10B-7 and OTP R10B-8.
The attached patch allows Yaws deflate to work with either API.
(Currently, it only works with R10B-7 and previous).
The R10B-7 zlib:deflate() returns {ok, Ret}.
The R10B-8 zlib:deflate() returns just Ret.
Post recived from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Wed Sep 06, 2006 1:57 am |
|
|
|
Guest
|
On 9/5/06, Matthew Reilly <matthew.reilly@sipphone.com> wrote:
> The yaws_zlib:deflate() function makes use of the OTP zlib:deflate()
> function. Unfortunately the API for zlib:deflate() changed between OTP
> R10B-7 and OTP R10B-8.
>
> The attached patch allows Yaws deflate to work with either API.
> (Currently, it only works with R10B-7 and previous).
>
> The R10B-7 zlib:deflate() returns {ok, Ret}.
> The R10B-8 zlib:deflate() returns just Ret.
>
>
> diff -Nurp yawsORIG/src/yaws_zlib.erl yawsPATCHED/src/yaws_zlib.erl
> --- yawsORIG/src/yaws_zlib.erl 2006-09-05 16:35:13.000000000 -0700
> +++ yawsPATCHED/src/yaws_zlib.erl 2006-09-05 16:35:31.000000000 -0700
> @@ -34,7 +34,10 @@ gzipDeflate(Z, undefined, Bin, Flush) ->
> {ok, Priv, [Head | Bs]};
>
> gzipDeflate(Z, {Crc32,Size}, Bin, Flush) ->
> - {ok, Bs} = zlib:deflate(Z, Bin, Flush),
> + Bs = case zlib:deflate(Z, Bin, Flush) of
> + {ok, Bs1} -> Bs1;
> + Bs1 -> Bs1
> + end,
> {ok, Crc1} = crc32(Z, Crc32, Bin),
> Size1 = Size+size(Bin),
> Data =
>
Shouldn't you add a guard to Bs1 -> Bs1 to make sure it's a binary
instead of an {error, _} tuple?
-bob
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Wed Sep 06, 2006 3:00 am |
|
|
|
Guest
|
zlib:deflate() throws an error with erlang:error(badarg) instead of
returning {error, Error}.
In OTP R10-8 and later, zlib:deflate() is guaranteed to return a list
(of binaries) if it doesn't throw a badarg. We could easily check for a
return type of list, but it won't catch any extra errors, but I can send
another patch with an extra guard if you wish.
-Matt
Bob Ippolito wrote:
> On 9/5/06, Matthew Reilly <matthew.reilly@sipphone.com> wrote:
>> The yaws_zlib:deflate() function makes use of the OTP zlib:deflate()
>> function. Unfortunately the API for zlib:deflate() changed between OTP
>> R10B-7 and OTP R10B-8.
>>
>> The attached patch allows Yaws deflate to work with either API.
>> (Currently, it only works with R10B-7 and previous).
>>
>> The R10B-7 zlib:deflate() returns {ok, Ret}.
>> The R10B-8 zlib:deflate() returns just Ret.
>>
>>
>> diff -Nurp yawsORIG/src/yaws_zlib.erl yawsPATCHED/src/yaws_zlib.erl
>> --- yawsORIG/src/yaws_zlib.erl 2006-09-05 16:35:13.000000000 -0700
>> +++ yawsPATCHED/src/yaws_zlib.erl 2006-09-05 16:35:31.000000000
>> -0700
>> @@ -34,7 +34,10 @@ gzipDeflate(Z, undefined, Bin, Flush) ->
>> {ok, Priv, [Head | Bs]};
>>
>> gzipDeflate(Z, {Crc32,Size}, Bin, Flush) ->
>> - {ok, Bs} = zlib:deflate(Z, Bin, Flush),
>> + Bs = case zlib:deflate(Z, Bin, Flush) of
>> + {ok, Bs1} -> Bs1;
>> + Bs1 -> Bs1
>> + end,
>> {ok, Crc1} = crc32(Z, Crc32, Bin),
>> Size1 = Size+size(Bin),
>> Data =
>>
>
> Shouldn't you add a guard to Bs1 -> Bs1 to make sure it's a binary
> instead of an {error, _} tuple?
>
> -bob
>
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Wed Sep 06, 2006 6:29 am |
|
|
|
Guest
|
My previous reply made absolutely no sense what-so-ever. I can't just
take into account the new API if the old API could return an error code
instead of throwing an exception (which is does). Looking through an
earlier implementation of zlib:deflate(), it looks like it returns
{'EXIT', Reason} on error.
I've attached a new version of the patch which checks the return from
zlib:deflate() to make sure it is a list. Any previous error condition
should come as a tuple which wouldn't match a list.
I hope I got it right this time,
Matt
Matthew Reilly wrote:
> zlib:deflate() throws an error with erlang:error(badarg) instead of
> returning {error, Error}.
>
> In OTP R10-8 and later, zlib:deflate() is guaranteed to return a list
> (of binaries) if it doesn't throw a badarg. We could easily check for a
> return type of list, but it won't catch any extra errors, but I can send
> another patch with an extra guard if you wish.
>
> -Matt
>
> Bob Ippolito wrote:
>> On 9/5/06, Matthew Reilly <matthew.reilly@sipphone.com> wrote:
>>> The yaws_zlib:deflate() function makes use of the OTP zlib:deflate()
>>> function. Unfortunately the API for zlib:deflate() changed between OTP
>>> R10B-7 and OTP R10B-8.
>>>
>>> The attached patch allows Yaws deflate to work with either API.
>>> (Currently, it only works with R10B-7 and previous).
>>>
>>> The R10B-7 zlib:deflate() returns {ok, Ret}.
>>> The R10B-8 zlib:deflate() returns just Ret.
>>>
>>>
>>> diff -Nurp yawsORIG/src/yaws_zlib.erl yawsPATCHED/src/yaws_zlib.erl
>>> --- yawsORIG/src/yaws_zlib.erl 2006-09-05 16:35:13.000000000 -0700
>>> +++ yawsPATCHED/src/yaws_zlib.erl 2006-09-05 16:35:31.000000000
>>> -0700
>>> @@ -34,7 +34,10 @@ gzipDeflate(Z, undefined, Bin, Flush) ->
>>> {ok, Priv, [Head | Bs]};
>>>
>>> gzipDeflate(Z, {Crc32,Size}, Bin, Flush) ->
>>> - {ok, Bs} = zlib:deflate(Z, Bin, Flush),
>>> + Bs = case zlib:deflate(Z, Bin, Flush) of
>>> + {ok, Bs1} -> Bs1;
>>> + Bs1 -> Bs1
>>> + end,
>>> {ok, Crc1} = crc32(Z, Crc32, Bin),
>>> Size1 = Size+size(Bin),
>>> Data =
>>>
>> Shouldn't you add a guard to Bs1 -> Bs1 to make sure it's a binary
>> instead of an {error, _} tuple?
>>
>> -bob
>>
>
>
> -------------------------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Erlyaws-list mailing list
> Erlyaws-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/erlyaws-list
>
Post recived from mailinglist |
|
|
| Back to top |
|
| Guest |
Posted: Wed Sep 06, 2006 8:07 am |
|
|
|
Guest
|
Matthew Reilly wrote:
>
> gzipDeflate(Z, {Crc32,Size}, Bin, Flush) ->
> - {ok, Bs} = zlib:deflate(Z, Bin, Flush),
> + Bs = case zlib:deflate(Z, Bin, Flush) of
> + {ok, Bs1} -> Bs1;
> + Bs1 when is_list(Bs1) -> Bs1
> + end,
> {ok, Crc1} = crc32(Z, Crc32, Bin),
> Size1 = Size+size(Bin),
> Data =
Excellent, thanks. Will be in next release.
/klacke
--
Claes Wikstrom -- Caps lock is nowhere and
http://www.tail-f.com -- everything is under control
cellphone: +46 70 2097763
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/erlyaws-list
Post recived from mailinglist |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|
|