Login | Register
My pages Projects Community openCollabNet

Discussions > cvs > CVS update: MODIFIED: publish ...

Project highlights: Architectural Overview

joist
Discussion topic

Back to topic list

CVS update: MODIFIED: publish ...

Author stack
Full name Michael Stack
Date 2001-06-17 23:02:00 PDT
Message User: stack
  Date: 01/06/17 23:02:00

  Modified: java/org/joist/publish Tag: TIGRIS_1_0 ProxyModule.java
  Log:
  Add support for HEAD requests (Our non-support was generating NPEs).
  Use the HTTPClient.getData instead of the readFully method. The latter
  generates IOException errors when 'Connection: close' header is present
  inthe request. Add better reporting when errors reading request data.
  
  The above changes purportedly fix 404s experienced by browsers on other
  side of a forward proxy cache (To be confirmed).
  
  Reviewed by: Jason Robbins
  
  Revision Changes Path
  No revision
  
  http://joist.tigris.​org/source/browse/jo​ist/java/org/joist/p​ublish/Tag:
  No revision
  
  http://joist.tigris.​org/source/browse/jo​ist/java/org/joist/p​ublish/TIGRIS_1_0
  1.11.6.4 +47 -14 joist/java/org/joist​/publish/ProxyModule​.java
  
  http://joist.tigris.​org/source/browse/jo​ist/java/org/joist/p​ublish/ProxyModule.j​ava.diff?r1=1.11.6.3​&r2=1.11.6.4
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ProxyModule.java
  ====================​====================​====================​=======
  RCS file: /usr/local/tigris/da​ta/helm/cvs/reposito​ry/joist/java/org/jo​ist/publish/ProxyMod​ule.java,v
  retrieving revision 1.11.6.3
  retrieving revision 1.11.6.4
  diff -u -b -r1.11.6.3 -r1.11.6.4
  --- ProxyModule.java 2001/06/14 18:10:45 1.11.6.3
  +++ ProxyModule.java 2001/06/18 06:02:00 1.11.6.4
  @@ -93,6 +93,8 @@
   
       public static final String POST = "POST";
       public static final String GET = "GET";
  + public static final String PUT = "PUT";
  + public static final String HEAD = "HEAD";
       
   
       /**
  @@ -161,6 +163,8 @@
   
           boolean methodGet = req.getMethod().equa​lsIgnoreCase(GET);
           boolean methodPost = req.getMethod().equa​lsIgnoreCase(POST);
  + boolean methodHEAD = req.getMethod().equa​lsIgnoreCase(HEAD);
  + boolean methodPUT = req.getMethod().equa​lsIgnoreCase(PUT);
   
           // deal with QUERYSTRING data.
           //
  @@ -226,34 +230,52 @@
               sb.append(noodleData​.getQueryData());
           }
   
  + conn = new HTTPConnection(noodl​eData.getURL());
  + HTTPResponse httpResponse = null;
  +
           if (methodGet)
           {
  - conn = new HTTPConnection(noodl​eData.getURL());
  - noodleData.setHTTPResponse(
  - conn.Get(sb.toString(), new String(),
  - noodleData.getHeader​sToSendAsNVPair()));​
  + httpResponse = conn.Get(sb.toString(), new String(),
  + noodleData.getHeader​sToSendAsNVPair());
           }
           else if (methodPost)
           {
  - conn = new HTTPConnection(noodl​eData.getURL());
  - noodleData.setHTTPResponse(
  - conn.Post(sb.toString(),
  - noodleData.getPostData(),
  - noodleData.getHeader​sToSendAsNVPair()));​
  + httpResponse = conn.Post(sb.toString(), noodleData.getPostData(),
  + noodleData.getHeader​sToSendAsNVPair());
  + }
  + else if( methodHEAD )
  + {
  + httpResponse = conn.Head(sb.toString(), new String(),
  + noodleData.getHeader​sToSendAsNVPair());
           }
  + else if( methodPUT )
  + {
  + httpResponse = conn.Put(sb.toString(), new String(),
  + noodleData.getHeader​sToSendAsNVPair());
  + }
  + else
  + {
  + throw new java.net.ProtocolException( "UNSUPPORTED HTTP method: "
  + + req.getMethod( ) );
  + }
  +
  + noodleData.setHTTPResponse( httpResponse );
           
           // get the content from the response to the connection
           byte[] data = null;
           String ct = null;
           try
           {
  + // 'readFully' seems to have problems when a 'Connection: close'
  + // header is passed. The HTTPClient library getData( ) seems
  + // to work. St.Ack
               // read response data from the stream
  - data = readFully(
  - new BufferedInputStream(
  - noodleData.getHTTPRe​sponse().getInputStr​eam()));
  + // data = readFully(
  + // new BufferedInputStream(
  + // noodleData.getHTTPRe​sponse().getInputStr​eam()));
               // i think the above line is more efficient than what
               // HTTPClient.Response is trying to do....ie:
  - // data = noodleData.getHTTPRe​sponse().getData();
  + data = noodleData.getHTTPRe​sponse().getData();
   
               // get the content type
               ct = noodleData.getHTTPRe​sponse().getHeader("​Content-Type");
  @@ -264,7 +286,18 @@
           catch (Exception e)
           {
               // this is a hack
  - Log.error( "Error occurred while accessing content.", e );
  + Log.error( "Error occurred while accessing content:"
  + + noodleData.getURL( ).toString( ), e );
  + Vector v = noodleData.getHeadersToSend( );
  + StringBuffer strbuf = new StringBuffer( );
  + for( int i = 0; i < v.size( ); i++ )
  + {
  + strbuf.append( ( ( NVPair )v.get( i ) ).getName( ) );
  + strbuf.append( ":" );
  + strbuf.append( ( ( NVPair )v.get( i ) ).getValue( ) );
  + strbuf.append( "===" );
  + }
  + Log.error( "REQUEST HEADERS: " + strbuf.toString( ) );
               data = "Error occurred while accessing content.".getBytes();
               ct = DEFAULT_CONTENT_TYPE;
           }
  
  
  

--------------------​--------------------​--------------------​---------
To unsubscribe, e-mail: cvs-unsubscribe@jois​t.tigris.org
For additional commands, e-mail: cvs-help at joist dot tigris dot org

« Previous message in topic | 1 of 1 | Next message in topic »

Messages

Show all messages in topic

CVS update: MODIFIED: publish ... stack Michael Stack 2001-06-17 23:02:00 PDT
Messages per page: