You are viewing a plain text version of this content. The canonical link for it is here.
Posted to awf-commits@incubator.apache.org by sl...@apache.org on 2012/03/04 16:47:52 UTC
svn commit: r1296834 - in /incubator/awf/trunk/awf-core/src:
main/java/org/apache/awf/web/http/HttpRequestImpl.java
main/java/org/apache/awf/web/http/HttpRequestParser.java
test/java/org/apache/awf/web/SystemTest.java
Author: slemesle
Date: Sun Mar 4 16:47:52 2012
New Revision: 1296834
URL: http://svn.apache.org/viewvc?rev=1296834&view=rev
Log:
Fix CI
Modified:
incubator/awf/trunk/awf-core/src/main/java/org/apache/awf/web/http/HttpRequestImpl.java
incubator/awf/trunk/awf-core/src/main/java/org/apache/awf/web/http/HttpRequestParser.java
incubator/awf/trunk/awf-core/src/test/java/org/apache/awf/web/SystemTest.java
Modified: incubator/awf/trunk/awf-core/src/main/java/org/apache/awf/web/http/HttpRequestImpl.java
URL: http://svn.apache.org/viewvc/incubator/awf/trunk/awf-core/src/main/java/org/apache/awf/web/http/HttpRequestImpl.java?rev=1296834&r1=1296833&r2=1296834&view=diff
==============================================================================
--- incubator/awf/trunk/awf-core/src/main/java/org/apache/awf/web/http/HttpRequestImpl.java (original)
+++ incubator/awf/trunk/awf-core/src/main/java/org/apache/awf/web/http/HttpRequestImpl.java Sun Mar 4 16:47:52 2012
@@ -371,6 +371,18 @@ public class HttpRequestImpl implements
return contentLength;
}
+ /**
+ * Check wether this request body uses chunked encoding
+ * @return
+ */
+ public boolean isChunked(){
+ String te =headers.get("transfer-encoding");
+ if (te != null){
+ return te.indexOf("chunked") > -1;
+ }
+ return false;
+ }
+
protected void incrementChunkSize(int size){
chunkedSize += size;
@@ -389,7 +401,7 @@ public class HttpRequestImpl implements
if (res ){
if (contentLength > 0){
res = contentLength <= bodyBuffer.position();
- }else {
+ }else if (isChunked()){
res = context.chunked;
}
}
Modified: incubator/awf/trunk/awf-core/src/main/java/org/apache/awf/web/http/HttpRequestParser.java
URL: http://svn.apache.org/viewvc/incubator/awf/trunk/awf-core/src/main/java/org/apache/awf/web/http/HttpRequestParser.java?rev=1296834&r1=1296833&r2=1296834&view=diff
==============================================================================
--- incubator/awf/trunk/awf-core/src/main/java/org/apache/awf/web/http/HttpRequestParser.java (original)
+++ incubator/awf/trunk/awf-core/src/main/java/org/apache/awf/web/http/HttpRequestParser.java Sun Mar 4 16:47:52 2012
@@ -72,6 +72,11 @@ public class HttpRequestParser {
if(context.chunkSize > 0){
status = pushChunkToBody(buffer, result, context);
}
+ // Copy body data to the request bodyBuffer
+ if (context.isbodyFound() && result.getContentLength() > 0){
+ pushRemainingToBody(context.buffer, result.getBodyBuffer(), result.getContentLength());
+ status = 0;
+ }
// while no errors and buffer not finished
while ((status = lexer.nextToken(context)) > 0){
@@ -98,7 +103,7 @@ public class HttpRequestParser {
if (result.getContentLength() > 0){
pushRemainingToBody(context.buffer, result.getBodyBuffer(), result.getContentLength());
status = 0;
- }else if (!context.chunked){
+ }else if (result.isChunked() && !context.chunked){
context.chunked =true;
context.currentType = HttpParsingContext.TokenType.CHUNK_OCTET;
result.buildChunkedBody();
@@ -112,8 +117,8 @@ public class HttpRequestParser {
if (parts.length >0){
try {
context.chunkSize = Integer.parseInt(parts[0].trim(), 16);
- if (context.chunkSize == 0){// Last Chunk gets 0
- context.currentType = HttpParsingContext.TokenType.HEADER_NAME;
+ if (context.chunkSize == 0){// Last Chunk gets 0 so we can try to read footers
+ context.currentType = HttpParsingContext.TokenType.HTTP_VERSION;
}else {
result.incrementChunkSize(context.chunkSize);
context.incrementAndGetPointer();
Modified: incubator/awf/trunk/awf-core/src/test/java/org/apache/awf/web/SystemTest.java
URL: http://svn.apache.org/viewvc/incubator/awf/trunk/awf-core/src/test/java/org/apache/awf/web/SystemTest.java?rev=1296834&r1=1296833&r2=1296834&view=diff
==============================================================================
--- incubator/awf/trunk/awf-core/src/test/java/org/apache/awf/web/SystemTest.java (original)
+++ incubator/awf/trunk/awf-core/src/test/java/org/apache/awf/web/SystemTest.java Sun Mar 4 16:47:52 2012
@@ -1110,7 +1110,7 @@ public class SystemTest {
@Test
public void serverChunkedBodyRequest()throws Exception{
HttpClient httpclient = new DefaultHttpClient();
- HttpPost httpPost = new HttpPost("http://localhost:" + PORT + "/query_params?key1=value1&key2=value2");
+ HttpPost httpPost = new HttpPost("http://localhost:" + PORT + "/echo");
StringEntity se = new StringEntity("azertyuiopqsdfghjklmwxc\nvbn1234567890");
se.setChunked(true);
httpPost.setEntity(se);