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-18 11:22:23 PDT
Message User: stack
  Date: 01/06/18 11:22:23

  Modified: java/org/joist/publish ProxyModule.java
  Log:
  Add handling of HEAD and PUT requests (indexers do HEAD requests).
  Remove blinding of an exception. Instead log it w/ details on
  the request made.
  
  Revision Changes Path
  1.12 +45 -17 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​&r2=1.12
  
  (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
  retrieving revision 1.12
  diff -u -b -r1.11 -r1.12
  --- ProxyModule.java 2001/02/21 01:35:11 1.11
  +++ ProxyModule.java 2001/06/18 18:22:23 1.12
  @@ -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,45 +230,69 @@
               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
           {
  - // read response data from the stream
               data = readFully(
  - new BufferedInputStream(
  - noodleData.getHTTPRe​sponse().getInputStr​eam()));
  + new BufferedInputStream( httpResponse.getInpu​tStream()));
               // i think the above line is more efficient than what
               // HTTPClient.Response is trying to do....ie:
  - // data = noodleData.getHTTPRe​sponse().getData();
  + // data = httpResponse.getData();
   
               // get the content type
  - ct = noodleData.getHTTPRe​sponse().getHeader("​Content-Type");
  + ct = httpResponse.getHead​er("Content-Type");
               // case for Content-Type: being missing for some reason
               if (ct == null || ct.length() == 0)
                   ct = DEFAULT_CONTENT_TYPE;
           }
           catch (Exception e)
           {
  - // this is a hack
  - data = "404 File Not Found".getBytes();
  + 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-18 11:22:23 PDT
Messages per page: