You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@excalibur.apache.org by cz...@apache.org on 2005/07/27 21:50:37 UTC

svn commit: r225589 - /excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/impl/URLSource.java

Author: cziegeler
Date: Wed Jul 27 12:50:33 2005
New Revision: 225589

URL: http://svn.apache.org/viewcvs?rev=225589&view=rev
Log:
This hopefully fixes bug EXLBR-19

Modified:
    excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/impl/URLSource.java

Modified: excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/impl/URLSource.java
URL: http://svn.apache.org/viewcvs/excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/impl/URLSource.java?rev=225589&r1=225588&r2=225589&view=diff
==============================================================================
--- excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/impl/URLSource.java (original)
+++ excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/impl/URLSource.java Wed Jul 27 12:50:33 2005
@@ -165,7 +165,32 @@
                 m_mimeType = m_connection.getContentType();
                 int contentLength = m_connection.getContentLength();
                 setContentLength(contentLength);
-                m_exists = contentLength >= 0;
+                if ( m_connection instanceof HttpURLConnection )
+                {
+                    // check the status code for exists
+                    // if the url does not exists we might also get an IOException here!
+                    try 
+                    {
+                        final int statusCode = ((HttpURLConnection)m_connection).getResponseCode();
+                        if ( statusCode == 200 || statusCode == 303 || statusCode == 304 )
+                        {
+                            m_exists = true;
+                        } 
+                        else
+                        {
+                            m_exists = false;
+                        }                        
+                    }
+                    catch (IOException ignore)
+                    {
+                        m_exists = false;
+                    }
+                        
+                } 
+                else 
+                {
+                    m_exists = contentLength >= 0;
+                }
             }
             catch (IOException ignore)
             {



---------------------------------------------------------------------
To unsubscribe, e-mail: scm-unsubscribe@excalibur.apache.org
For additional commands, e-mail: scm-help@excalibur.apache.org


Re: svn commit: r225589

Posted by Carsten Ziegeler <cz...@apache.org>.
Leo Simons wrote:

> 
> IMHO someone should rewrite sourceresolver to use jakarta httpclient. There
> are too many badly behaving http clients out there :-)
> 
We already have an implementation: HTTPClientSource
But I'm not sure if this can be used as a drop-in replacement for the
uri source; I'll check this next week.

Carsten

-- 
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@excalibur.apache.org
For additional commands, e-mail: dev-help@excalibur.apache.org


Re: svn commit: r225589

Posted by Leo Simons <ma...@leosimons.com>.
On 28-07-2005 17:11, "Carsten Ziegeler" <cz...@apache.org> wrote:
> Vadim Gritsenko schrieb:
>> cziegeler-1oDqGaOF3Lkdnm+yROfE0A@public.gmane.org wrote:
>> Are you sure you meant 303 [1]? Then you should include 301 and 307 as well.
>> 
>> Also, codes 500, 502, 503, 504 can happen on existing resource depending on
>> server(s)/network load [2].
>> 
> Hmm, yeah, you're right - I think we should remove 303 from the list.
> Can you do this please? I can't do it in the next days and there will be
> new release candidates very soon.

IMHO someone should rewrite sourceresolver to use jakarta httpclient. There
are too many badly behaving http clients out there :-)

LSD



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@excalibur.apache.org
For additional commands, e-mail: dev-help@excalibur.apache.org


Re: svn commit: r225589 - /excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/impl/URLSource.java

Posted by Carsten Ziegeler <cz...@apache.org>.
Vadim Gritsenko schrieb:
> cziegeler-1oDqGaOF3Lkdnm+yROfE0A@public.gmane.org wrote:
> 
>>Author: cziegeler
>>Date: Wed Jul 27 12:50:33 2005
>>New Revision: 225589
>>
>>URL: http://svn.apache.org/viewcvs?rev=225589&view=rev
>>Log:
>>This hopefully fixes bug EXLBR-19
>>
>>+                    // check the status code for exists
>>+                    // if the url does not exists we might also get an IOException here!
>>+                    try 
>>+                    {
>>+                        final int statusCode = ((HttpURLConnection)m_connection).getResponseCode();
>>+                        if ( statusCode == 200 || statusCode == 303 || statusCode == 304 )
>>+                        {
> 
> 
> Are you sure you meant 303 [1]? Then you should include 301 and 307 as well.
> 
> Also, codes 500, 502, 503, 504 can happen on existing resource depending on 
> server(s)/network load [2].
> 
> 
Hmm, yeah, you're right - I think we should remove 303 from the list.
Can you do this please? I can't do it in the next days and there will be
new release candidates very soon.

Carsten

-- 
Carsten Ziegeler - Open Source Group, S&N AG
http://www.s-und-n.de
http://www.osoco.org/weblogs/rael/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@excalibur.apache.org
For additional commands, e-mail: dev-help@excalibur.apache.org


Re: svn commit: r225589 - /excalibur/trunk/components/sourceresolve/src/java/org/apache/excalibur/source/impl/URLSource.java

Posted by Vadim Gritsenko <va...@reverycodes.com>.
cziegeler-1oDqGaOF3Lkdnm+yROfE0A@public.gmane.org wrote:
> Author: cziegeler
> Date: Wed Jul 27 12:50:33 2005
> New Revision: 225589
> 
> URL: http://svn.apache.org/viewcvs?rev=225589&view=rev
> Log:
> This hopefully fixes bug EXLBR-19
> 
> +                    // check the status code for exists
> +                    // if the url does not exists we might also get an IOException here!
> +                    try 
> +                    {
> +                        final int statusCode = ((HttpURLConnection)m_connection).getResponseCode();
> +                        if ( statusCode == 200 || statusCode == 303 || statusCode == 304 )
> +                        {

Are you sure you meant 303 [1]? Then you should include 301 and 307 as well.

Also, codes 500, 502, 503, 504 can happen on existing resource depending on 
server(s)/network load [2].


Vadim

> +                            m_exists = true;
> +                        } 
> +                        else
> +                        {
> +                            m_exists = false;
> +                        }                        
> +                    }


[1] 10.3.4 303 See Other

The response to the request can be found under a different URI and SHOULD be 
retrieved using a GET method on that resource. This method exists primarily to 
allow the output of a POST-activated script to redirect the user agent to a 
selected resource.

[2] http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@excalibur.apache.org
For additional commands, e-mail: dev-help@excalibur.apache.org