Details
Description
Both the HTTP Client step and the HTTP Post step utilise the
org.apache.commons.httpclient libraries for HTTP requests. This library automatically tries basic authentication and then digest authentication if basic fails. Unfortunately the HTTP Post step fails with the following error:
2018/03/14 18:18:23 - HTTP Post.0 - ERROR (version 7.1.0.3-57, build 1 from 2017-08-23 11.43.14 by buildguy) : Because of an error, this step can't continue: 2018/03/14 18:18:23 - HTTP Post.0 - ERROR (version 7.1.0.3-57, build 1 from 2017-08-23 11.43.14 by buildguy) : Because of an error, this step can't continue: 2018/03/14 18:18:23 - HTTP Post.0 - Can not result from [http://b401-001-camc.bms.curtin.edu.au/admin-bin/editcgi.cgi?file=/usr/local/package/fallback_parameters.json]2018/03/14 18:18:23 - HTTP Post.0 - Unbuffered entity enclosing request can not be repeated. 2018/03/14 18:18:23 - HTTP Post.0 - ERROR (version 7.1.0.3-57, build 1 from 2017-08-23 11.43.14 by buildguy) : org.pentaho.di.core.exception.KettleException: 2018/03/14 18:18:23 - HTTP Post.0 - Can not result from [http://b401-001-camc.bms.curtin.edu.au/admin-bin/editcgi.cgi?file=/usr/local/package/fallback_parameters.json]2018/03/14 18:18:23 - HTTP Post.0 - Unbuffered entity enclosing request can not be repeated. 2018/03/14 18:18:23 - HTTP Post.0 - 2018/03/14 18:18:23 - HTTP Post.0 - at org.pentaho.di.trans.steps.httppost.HTTPPOST.callHTTPPOST(HTTPPOST.java:326) 2018/03/14 18:18:23 - HTTP Post.0 - at org.pentaho.di.trans.steps.httppost.HTTPPOST.processRow(HTTPPOST.java:472) 2018/03/14 18:18:23 - HTTP Post.0 - at org.pentaho.di.trans.step.RunThread.run(RunThread.java:62) 2018/03/14 18:18:23 - HTTP Post.0 - at java.lang.Thread.run(Thread.java:748) 2018/03/14 18:18:23 - HTTP Post.0 - Caused by: org.apache.commons.httpclient.ProtocolException: Unbuffered entity enclosing request can not be repeated. 2018/03/14 18:18:23 - HTTP Post.0 - at org.apache.commons.httpclient.methods.EntityEnclosingMethod.writeRequestBody(EntityEnclosingMethod.java:487) 2018/03/14 18:18:23 - HTTP Post.0 - at org.apache.commons.httpclient.HttpMethodBase.writeRequest(HttpMethodBase.java:2114) 2018/03/14 18:18:23 - HTTP Post.0 - at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:1096) 2018/03/14 18:18:23 - HTTP Post.0 - at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:398) 2018/03/14 18:18:23 - HTTP Post.0 - at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171) 2018/03/14 18:18:23 - HTTP Post.0 - at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397) 2018/03/14 18:18:23 - HTTP Post.0 - at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:346) 2018/03/14 18:18:23 - HTTP Post.0 - at org.pentaho.di.trans.steps.httppost.HTTPPOST.requestStatusCode(HTTPPOST.java:336) 2018/03/14 18:18:23 - HTTP Post.0 - at org.pentaho.di.trans.steps.httppost.HTTPPOST.callHTTPPOST(HTTPPOST.java:217) 2018/03/14 18:18:23 - HTTP Post.0 - ... 3 more
I've found changing line 201 of engine/src/org/pentaho/di/trans/steps/httppost/HTTPPOST.java from:
post.setRequestEntity( new InputStreamRequestEntity( new ByteArrayInputStream( bytes ), bytes.length ) );
to
post.setRequestEntity( new org.apache.commons.httpclient.methods.ByteArrayRequestEntity(bytes));
this error goes away and HttpClient.executeMethod retries the authentication successfully as Digest authentication.