You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ivy-user@ant.apache.org by Jeffrey Sinclair <je...@cooljeff.co.uk> on 2008/11/24 23:14:20 UTC

URLResolver's dependency on URLConnection.getContentLength()

I've been trying to use the URLResolver with a custom protocol that
returns -1 for URLConnection.getContentLength(). The problem I'm seeing
is that for my custom protocol, resources can never be found.

After a little debugging I found the following code in
org.apache.ivy.util.url.BasicURLHandler.getURLInfo() which explains why
I'm running into issues:
 

    public URLInfo getURLInfo(URL url, int timeout) {

...
            if (con instanceof HttpURLConnection) {
               ...
            } else {

                int contentLength = con.getContentLength();

                if (contentLength <= 0) {

                    return UNAVAILABLE;

                } else {

                   ...
                }

            }

        } 

Is this a bug in the URLResolver? For certain resources which are
streamed, the content length will not be known so I'm not sure that
UNAVAILABLE should be dependent on the content length.

Regards,

Jeff

 


Re: URLResolver's dependency on URLConnection.getContentLength()

Posted by Jeffrey Sinclair <je...@cooljeff.co.uk>.
> Could you create a JIRA ticket?
 
https://issues.apache.org/jira/browse/IVY-979

On Mon, 2008-11-24 at 14:49 -0800, Maarten Coene wrote:
> I don't know if it will be easy to support such a thing because the URLInfo.getContentLength() might be used in different places.
> We should investigate this further to see if Ivy could deal with an unknown content-length.
> Could you create a JIRA ticket?
> 
> Maarten
> 
> 
> 
> ----- Original Message ----
> From: Jeffrey Sinclair <je...@cooljeff.co.uk>
> To: ivy-user@ant.apache.org
> Sent: Monday, November 24, 2008 11:14:20 PM
> Subject: URLResolver's dependency on URLConnection.getContentLength()
> 
> I've been trying to use the URLResolver with a custom protocol that
> returns -1 for URLConnection.getContentLength(). The problem I'm seeing
> is that for my custom protocol, resources can never be found.
> 
> After a little debugging I found the following code in
> org.apache.ivy.util.url.BasicURLHandler.getURLInfo() which explains why
> I'm running into issues:
> 
> 
>     public URLInfo getURLInfo(URL url, int timeout) {
> 
> ...
>             if (con instanceof HttpURLConnection) {
>                ...
>             } else {
> 
>                 int contentLength = con.getContentLength();
> 
>                 if (contentLength <= 0) {
> 
>                     return UNAVAILABLE;
> 
>                 } else {
> 
>                    ...
>                 }
> 
>             }
> 
>         } 
> 
> Is this a bug in the URLResolver? For certain resources which are
> streamed, the content length will not be known so I'm not sure that
> UNAVAILABLE should be dependent on the content length.
> 
> Regards,
> 
> Jeff
> 
> 
>       


Re: URLResolver's dependency on URLConnection.getContentLength()

Posted by Maarten Coene <ma...@yahoo.com>.
I don't know if it will be easy to support such a thing because the URLInfo.getContentLength() might be used in different places.
We should investigate this further to see if Ivy could deal with an unknown content-length.
Could you create a JIRA ticket?

Maarten



----- Original Message ----
From: Jeffrey Sinclair <je...@cooljeff.co.uk>
To: ivy-user@ant.apache.org
Sent: Monday, November 24, 2008 11:14:20 PM
Subject: URLResolver's dependency on URLConnection.getContentLength()

I've been trying to use the URLResolver with a custom protocol that
returns -1 for URLConnection.getContentLength(). The problem I'm seeing
is that for my custom protocol, resources can never be found.

After a little debugging I found the following code in
org.apache.ivy.util.url.BasicURLHandler.getURLInfo() which explains why
I'm running into issues:


    public URLInfo getURLInfo(URL url, int timeout) {

...
            if (con instanceof HttpURLConnection) {
               ...
            } else {

                int contentLength = con.getContentLength();

                if (contentLength <= 0) {

                    return UNAVAILABLE;

                } else {

                   ...
                }

            }

        } 

Is this a bug in the URLResolver? For certain resources which are
streamed, the content length will not be known so I'm not sure that
UNAVAILABLE should be dependent on the content length.

Regards,

Jeff