Disable sending the Chunked request from camunda

Hi,

Please let me know the option to disable sending the chunked request to server from camunda client.

Hi,

Are you using Tomcat? In my experience, the Tomcat HTTP 1.1 connector seems to default to chunked encoding. I had to work around this once and an option was to drop back to HTTP 1.0 which does not support chunked encoding. The Tomcat connector grcefully falls back to support http 1.0.

Hence can you force the client to use HTTP 1.0 protocol?

regards

Rob

Deployed the camunda workflow in tomcat and sending request from camunda connector plugin to python(flask server) which does not support the chunked request.

Here is the solution.
you can have your own custome httpClient inside JavaDelegate and easily manage the setChunk proporty.

input.setChunked(false); is the trick try to make it true it will not work.

public class ApacheHttpClientPostDelegate implements JavaDelegate {

	public void execute(DelegateExecution execution) throws Exception {
		// TODO Auto-generated method stub
		  try {

				DefaultHttpClient httpClient = new DefaultHttpClient();
				HttpPost postRequest = new HttpPost(
					"your  URL goes here");
				String auth ="username" + ":" + "Password";
				byte[] encodedAuth = Base64.encodeBase64(  auth.getBytes(Charset.forName("ISO-8859-1")));
				String authHeader = "Basic " + new String(encodedAuth);
				String  payload=(String)execution.getVariable("var");
//				StringEntity input = new StringEntity("{\"qty\":100,\"name\":\"iPad 4\"}");
//				JsonValue  Jevent=SpinValues.jsonValue(payload).create();
				StringEntity input = new StringEntity(payload);
				input.setContentType("application/json");
				input.setChunked(false);
				postRequest.setEntity(input);
				postRequest.setHeader(HttpHeaders.AUTHORIZATION, authHeader);

				HttpResponse response = httpClient.execute(postRequest);

//				if (response.getStatusLine().getStatusCode() != 201) {
//					throw new RuntimeException("Failed : HTTP error code : "
//						+ response.getStatusLine().getStatusCode());
//				}
				
				JsonValue jsonValue = SpinValues.jsonValue((SpinJsonNode) response).create();
			Integer  c=(Integer) jsonValue.getValue().prop("count").numberValue();

				BufferedReader br = new BufferedReader(
		                        new InputStreamReader((response.getEntity().getContent())));

				String output;
				System.out.println("Output from Server .... \n");
				while ((output = br.readLine()) != null) {
					System.out.println(output);
				}

				httpClient.getConnectionManager().shutdown();
				
				execution.setVariable("response", "wel done");

			  } catch (MalformedURLException e) {

				e.printStackTrace();

			  } catch (IOException e) {

				e.printStackTrace();

			  }
		
	}
 
}
1 Like