cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vishal Mishra (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (CB-11067) Content-Length missing in multipart form upload header on Android
Date Wed, 22 Nov 2017 00:54:00 GMT

     [ https://issues.apache.org/jira/browse/CB-11067?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Vishal Mishra closed CB-11067.
------------------------------
    Resolution: Won't Fix

With the new features introduced in [XMLHttpRequest|https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest],
this plugin is not needed any more. Migrating from this plugin to using the new features of
[XMLHttpRequest|https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest], is explained
in this [Cordova blog post|https://cordova.apache.org/blog/2017/10/18/from-filetransfer-to-xhr2.html].

> Content-Length missing in multipart form upload header on Android
> -----------------------------------------------------------------
>
>                 Key: CB-11067
>                 URL: https://issues.apache.org/jira/browse/CB-11067
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-plugin-file-transfer (DEPRECATED)
>         Environment: Plugin version 1.5.0
> chunked = false
>            Reporter: Odd Christer Brovig
>              Labels: Android, triaged
>
> On iOS Content-Length is sent as part of header for multipart form. On Android only Content-Disposition
and Content-Type is sent.
> Is there a special reason for this? I see that the file size is read after the beforeData
is converted to bytes.
> From FileTransfer.java:
> {code:java}
>                     beforeData.append(LINE_START).append(BOUNDARY).append(LINE_END);
>                     beforeData.append("Content-Disposition: form-data; name=\"").append(fileKey).append("\";");
>                     beforeData.append(" filename=\"").append(fileName).append('"').append(LINE_END);
>                     beforeData.append("Content-Type: ").append(mimeType).append(LINE_END).append(LINE_END);
>                     byte[] beforeDataBytes = beforeData.toString().getBytes("UTF-8");
>                     byte[] tailParamsBytes = (LINE_END + LINE_START + BOUNDARY + LINE_START
+ LINE_END).getBytes("UTF-8");
> {code}
> From CDVFileTransfer.m:
> {code}
>     [postBodyBeforeFile appendData:formBoundaryData];
>     [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Disposition:
form-data; name=\"%@\"; filename=\"%@\"\r\n", fileKey, fileName] dataUsingEncoding:NSUTF8StringEncoding]];
>     if (mimeType != nil) {
>         [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n",
mimeType] dataUsingEncoding:NSUTF8StringEncoding]];
>     }
>     [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Length: %ld\r\n\r\n",
(long)[fileData length]] dataUsingEncoding:NSUTF8StringEncoding]];
> {code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Mime
View raw message