Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    HTTP Header lost when performing DS Add/Update operation for form with FileItem.

    Hi Isomorphic,

    I have a use case where an HTTP Header is not making it to the server and it appears to be related to the FileItem being on the form.

    Here is the RPCRequest, showing the header. However, once the request arrives at the server, the header is not there.

    Code:
    {
        "actionURL":"http://xxx/xxx/sc/IDACall", 
        "showPrompt":true, 
        "prompt":"Saving form...", 
        "transport":"hiddenFrame", 
        "promptStyle":"cursor", 
        "params":{
            "some-param":"some-param-value"
        }, 
        "httpHeaders":{
            "some-header":"some-header-value"
        }, 
        "bypassCache":true, 
        "data":{
            "values":{
    ...
            }, 
            "operationConfig":{
                "dataSource":"someDS", 
                "repo":null, 
                "operationType":"add", 
                "textMatchStyle":"exact"
            }, 
            "componentId":"isc_DynamicForm_5", 
            "appID":"builtinApplication", 
            "operation":"someDS_add", 
            "oldValues":{
            }
        }
    }
    The HTTP Header is being added by a customized RequestTransformer and the HTTP Header works in all other cases, and if the FileItem is removed from the problematic form, it works as well.

    SmartClient Version: v10.1p_2017-08-10/Pro Deployment (built 2017-08-10)

    Thanks

    #2
    FileItem uploads files to the server by using an HTML form post. There's no way to add an HTTP header with this approach. You will need to send the header information some other way, ,eg, as part of the form values.

    Note: it's recently become possible to use the XMLHttpRequest object to upload files instead, in which case adding HTTP headers would be possible. Switching over to this approach would require a lot of cross-browser testing with no functional improvement except obscure cases like this, so we haven't prioritized this work, but it would be a valid Feature Sponsorship.

    Comment


      #3
      Hi Isomorphic,

      Thank you for the followup.

      I have another question related to the same HTML form post with the FileItem.

      We have a special condition where we need to do a custom response, and specifically for the form with the FileItem, we have an issue.

      Code:
          @Override
          public DSResponse handleDSRequest(DSRequest req, RPCManager mgr, RequestContext ctx) throws Exception {
              if (isSomeSpecialCondition()) {
                  mgr.doCustomResponse();
      
                  ctx.response.sendError(HttpServletResponse.SC_FORBIDDEN, "Some error message.");
      
                  return null;
              }
      
              DSResponse resp = super.handleDSRequest(req, mgr, ctx);
              return resp;
          }
      In the case above, where (isSomeSpecialCondition() == true), the client hangs. It only hangs in the case of the form with the FileItem.

      From the browser, I can see the response with the 403 code.

      Thanks

      Comment


        #4
        Same underlying problem - you are responding to a form submit, so we don't have the ability to handle HTTP-level errors.

        Note that, for both cases (file upload and just normal request), we would recommend responding via the standard error handling mechanism rather than using doCustomResponse() to do error handling in another way. Per docs, doCustomResponse() is intended for use cases like downloading a file in response to an RPCRequest.

        Comment


          #5
          Hi Isomorphic,

          Thank you for the clarification.

          Regards

          Comment

          Working...
          X