You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Waldhoff, Rodney" <rw...@us.britannica.com> on 2002/02/11 05:28:32 UTC

RE: [httpclient] question regarding HttpMethod interface: getResp onseBody method

If a response contains zero bytes, I agree we should return a zero byte
array (and I suspect that's what we do).  

If there has been no response, or that response has no body, then null is
not only a valid response, but I'd argue the best one.

null and byte[0] don't mean the same thing.

-----Original Message-----
From: Sean C. Sullivan
To: Jakarta Commons Developers List
Sent: 2/10/02 1:48 AM
Subject: [httpclient] question regarding HttpMethod interface:
getResponseBody method


jakarta-commons httpclient inquiry:


Currently, HttpMethod.java (an interface) defines a 
method called "getResponseBody":

    /**
     * Return my response body, if any,
     * as a byte array.
     * Otherwise return <tt>null</tt>.
     */
    public byte[] getResponseBody();


I would prefer if this method returns a  zero-length array instead 
of null.

Returning a zero-length array is one of the API design tips that
is recommended in Josh Bloch's book:

       Effective Java Programming Language Guide
       http://www.amazon.com/exec/obidos/ASIN/0201310058/


==> Item 27: Return zero-length arrays, not nulls


Regards,

-Sean



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>