jicarilla-sandbox/platform/components/http/impl/src/java/org/jicarilla/http HTTPParserImpl.java,1.11,1.12
Leo Simons <[email protected]>
| Newsgroups | gmane.comp.java.jicarilla.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/impl/src/java/org/jicarilla/http
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19517/platform/components/http/impl/src/java/org/jicarilla/http
Modified Files:
HTTPParserImpl.java
Log Message:
replace assertions with exceptions
Index: HTTPParserImpl.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/impl/src/java/org/jicarilla/http/HTTPParserImpl.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- HTTPParserImpl.java 4 Apr 2004 14:16:45 -0000 1.11
+++ HTTPParserImpl.java 6 Apr 2004 13:37:14 -0000 1.12
@@ -43,7 +43,6 @@
* <li>400 if a byte is encountered that is not acceptable for the current
* part of a message.</li>
*
- * @todo probably replace all uses of Assert with exception throwing
* @todo more javadocs
* @author <a href="lsimons at jicarilla dot org">Leo Simons</a>
* @version $Id$
@@ -751,7 +750,14 @@
{
// someone lame started the value with a CR. grmbl.
getContext().next();
- Assert.assertTrue( getContext().ch == HTTPEncoding.LF );
+ if( getContext().ch != HTTPEncoding.LF )
+ m_errorHandler.exceptionOccurred(
+ new HTTPException(
+ HTTPEncoding.STATUS_400_Bad_Request,
+ "CR without LF!"
+ )
+ );
+ //Assert.assertTrue( getContext().ch == HTTPEncoding.LF );
getContext().newView();
getContext().state = LOOKING_FOR_HEADER_VALUE_OR_NEXT_HEADER;
break;
@@ -917,7 +923,14 @@
{
// someone lame started the value with a CR. grmbl.
getContext().next();
- Assert.assertTrue( getContext().ch == HTTPEncoding.LF );
+ if( getContext().ch != HTTPEncoding.LF )
+ m_errorHandler.exceptionOccurred(
+ new HTTPException(
+ HTTPEncoding.STATUS_400_Bad_Request,
+ "CR without LF!"
+ )
+ );
+ //Assert.assertTrue( getContext().ch == HTTPEncoding.LF );
getContext().newView();
getContext().state = LOOKING_FOR_TRAILER_VALUE_OR_NEXT_TRAILER;
break;
@@ -1450,13 +1463,20 @@
}
/** retrieves expectingToSkipLF and sets it to false. */
- public boolean doSkipLF()
+ public boolean doSkipLF() throws HTTPException
{
final boolean tmp = expectingToSkipLF;
expectingToSkipLF = false;
- if(tmp)
- Assert.assertTrue( ch == HTTPEncoding.LF );
+ if( tmp && ch != HTTPEncoding.LF )
+ m_errorHandler.exceptionOccurred(
+ new HTTPException(
+ HTTPEncoding.STATUS_400_Bad_Request,
+ "CR without LF!"
+ )
+ );
+ //Assert.assertTrue( .ch == HTTPEncoding.LF );
+ //Assert.assertTrue( ch == HTTPEncoding.LF );
return tmp;
}
@@ -1615,12 +1635,19 @@
/**
* Sets {@link chunkSize}.
*/
- public void foundChunkSize()
+ public void foundChunkSize() throws HTTPException
{
getContext().markFieldLimit();
final ByteBuffer size = getContext().getAndUnsetView();
- Assert.assertTrue( "size may not be empty", size.hasRemaining() );
+ if( !size.hasRemaining() )
+ m_errorHandler.exceptionOccurred(
+ new HTTPException(
+ HTTPEncoding.STATUS_400_Bad_Request,
+ "size may not be empty!"
+ )
+ );
+ //Assert.assertTrue( "size may not be empty", size.hasRemaining() );
chunkSize = Integer.parseInt( NioUtil.toString( size ), 16 );
}
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click