[ 
https://issues.apache.org/jira/browse/NIFI-11496?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17720826#comment-17720826
 ] 

Andrew Robinson commented on NIFI-11496:
----------------------------------------

Each part of the multipart form will become its own flow file.

All flow files generated by a single request share the same 
http.context.identifier.

If you have a flow with a HandleHttpRequest which feeds straight into a 
HandleHttpResponse the HTTP Context Map knows which inbound request to respond 
to by the http.context.identifier. The client received its response when the 
first flow file with that identifier hit it. When future parts of the form are 
processed the inbound HTTP request is already completed (ie: the client 
received its response) and the http.context.identifier has been removed from 
the dictionary of the HTTP Context Map.

The way to solve this is to make sure only 1 flow file per 
http.context.identifier reaches the HandleHttpResponse.

Some options depending on your use case:
 * If you want to respond to the client when all parts of the request are 
processed, use Notify/Wait processors with a Release Signal Identifier of 
${http.context.identifier} so that only 1 flow file per request reaches the 
HandleHttpResponse.
 * If you want to respond to the client when a single part of the multipart 
form is processed you would need to decide which part, do a RouteOnAttribute to 
only allow 1 part for the upload to reach the HandleHttpResponse. For the other 
parts feed them to a terminating relationship. This would mean you have 
responded to the client without guaranteeing the successful processing of all 
parts of the form.

> HandleHttpRequest and HandleHttpResponse doesn't work with 
> "multipart/form-data" when sending multiple parts
> ------------------------------------------------------------------------------------------------------------
>
>                 Key: NIFI-11496
>                 URL: https://issues.apache.org/jira/browse/NIFI-11496
>             Project: Apache NiFi
>          Issue Type: Bug
>          Components: Extensions
>            Reporter: Kalmár Róbert
>            Priority: Major
>
> When sending a "multipart/form-data" request with multiple parts to a server 
> started with HandleHttpRequest, HandleHttpResponse will only process the 
> first form properly and will throw an exception for each following form:
> {code:java}
> 2023-04-28 13:40:59,721 ERROR [Timer-Driven Process Thread-2] 
> o.a.n.p.standard.HandleHttpResponse 
> HandleHttpResponse[id=c7a91d1a-0187-1000-1df6-5a49669a662d] Failed to respond 
> to HTTP request for 
> StandardFlowFileRecord[uuid=0c902106-9e8e-4091-9ccd-74ec2a124791,claim=StandardContentClaim
>  [resourceClaim=StandardResourceClaim[id=1682682059687-1, container=default, 
> section=1], offset=0, 
> length=19],offset=5,name=0c902106-9e8e-4091-9ccd-74ec2a124791,size=10] 
> because FlowFile had an 'http.context.identifier' attribute of 
> aa6aaf4e-3581-44b1-a6b4-368d6353835e but could not find an HTTP Response 
> Object for this identifier
>  {code}
> Each FlowFile after the first one will be routed to failure.
> Example curl command:
> {code:java}
> curl --location 'http://localhost:8000/simple' \
> --form 'fruit="apple"' \
> --form 'fruit="strawberry"' \
> --form 'fruit="pear"'{code}
> The response will be "apple"



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to