You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@chemistry.apache.org by "wentao lu (Jira)" <ji...@apache.org> on 2021/01/21 00:27:00 UTC

[jira] [Comment Edited] (CMIS-1071) filename are not set correctly on setContentStream

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

wentao lu edited comment on CMIS-1071 at 1/21/21, 12:26 AM:
------------------------------------------------------------

Hi Florian,

 

Looks like "Content-Disposition" is not a valid header for HttpRequestMessage, all "Content-" related headers have to be added into HttpContent.

So the easiest fix seems to do the same thing again on "content" object as you pointed out after line 182

 

if (content != null)
 {
        request.Headers.TransferEncodingChunked = true;
        request.Content = content;

       //try to add content headers here. 
       if (headers != null)
       {
             foreach (KeyValuePair<string, string> header in headers)
            {  

                content.Headers.TryAddWithoutValidation(header.Key, header.Value);    

            }

      }

     //end of add content headers here

}

Do you see any issues on this approach?

 

 

 

 

  


was (Author: welu):
Hi Florian,

 

Looks like "Content-Disposition" is not a valid header for HttpRequestMessage, all "Content-" related headers have to be added into HttpContent.

So the easiest fix seems to do the same thing again on "content" object as you pointed out after line 182

 

if (content != null)
 {
       request.Headers.TransferEncodingChunked = true;
       request.Content = content;

       //try to add content headers here. 
      if (headers != null)
      {
            foreach (KeyValuePair<string, string> header in headers)
           {
              content.Headers.TryAddWithoutValidation(header.Key, header.Value);
          }
     }

     //end of add content headers here

}

Do you see any issues on this approach?

 

 

 

 

  

> filename are not set correctly on setContentStream
> --------------------------------------------------
>
>                 Key: CMIS-1071
>                 URL: https://issues.apache.org/jira/browse/CMIS-1071
>             Project: Chemistry
>          Issue Type: Bug
>          Components: portcmis
>    Affects Versions: PortCMIS 0.3.0
>            Reporter: wentao lu
>            Assignee: Florian Müller
>            Priority: Major
>
> When use setContentStream, it does not be able to set the "Content-Disposition" header for some reasons. Please see below http message:
> PUT /cmis/atom/myrepository/content?id=idd_5087C169-0000-C515-9FB6-06967D7BF1C1&changeToken=0&overwriteFlag=false HTTP/1.1
> User-Agent: Apache-Chemistry-PortCMIS/0.3
> Content-Type: plain/text; charset=utf-8
> Authorization: Basic ZWNtY2VhZG1pbjpEZXYxUGFzc3dvcmQ=
> Host: localhost:4001
> Cookie: JSESSIONID=NqDBh0uyDIVrJvW0verrXFETDy4u_4IqSnJyDN2DOmIAxOrT2qSe!1962713399
> Transfer-Encoding: chunked
> Expect: 100-continue
> 9
> BANANA!!!
> 0
>  
> When call setContentStream using DotCMIS, it is able to set the file name via "Content-Disposition" header.
> PUT /cmis/atom/myrepository/content?id=idd_3089C569-0000-CE17-9119-FAC31AF1A146&changeToken=0&overwriteFlag=true HTTP/1.1
> User-Agent: Apache Chemistry DotCMIS
> Content-Type: application/msword
> Content-Disposition: attachment; filename*=UTF-8''AER%20New%20Use%20Cases%20-%20Draft.docx
> Authorization: Basic ZWNtY2VhZG1pbjpEZXYxUGFzc3dvcmQ=
> Host: localhost:4001
> Cookie: JSESSIONID=GWfFiTPPl2s2LLYLIh5-gN82XaJZ5rk3wPQz4ORtnm2ADmQJXhpn!1962713399
> Transfer-Encoding: chunked
> Expect: 100-continue
> When reviewing the code, it looks like the issue occurred on line 156 of HttpPortable.cs
> request.Headers.TryAddWithoutValidation(header.Key, header.Value);
> request is HttpRequestMessage
> On DotCMIS, it use:
> conn.Headers.Add(header.Key, header.Value);
> conn is HttpWebRequest.
>  
> Another different I see between DotCMIS and PortCMIS is the "content-type" header,
> DotCMIS get what it is from mimetype, i.e. 
>     Content-Type: application/msword
> However PortCMIS automatically add "charset=utf-8" which not always we want, 
>     Content-Type: plain/text; charset=utf-8
> We'd like developer can control what's been set in the header, if they need to add "charset", they can do it:
> string mimetype = "text/plain; charset=UTF-8";   //or
> string mimetype2 = "text/plain";  
> contentStream.MimeType = mimetype;
>  
> Thanks
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)