Re: multipart upload become garbage
Re: multipart upload become garbage
- Subject: Re: multipart upload become garbage
- From: Yung-Luen Lan <email@hidden>
- Date: Fri, 7 Jan 2011 00:27:21 +0800
It's been a while that I'm too busy to dig into this problem.
Anyway, I found the WebObjects FastCGI adaptor is buggy when you want
to upload binary files using form because the code use strncpy() to
copy the contents from HTTP request. It stop copy when a 0x00 byte
occur.
I was a bit surprise that few one complains about this (according to
quick search on google) since it's a severe defect that cause data
loss.
I wonder if people is still using WO fcgi adaptor. Nevertheless, I
have a patched version:
https://github.com/yllan/wonder
In case anyone still use the fcgi adaptor.
Regards,
yllan
On Thu, Sep 16, 2010 at 10:10 AM, Chuck Hill <email@hidden> wrote:
>
> On Sep 15, 2010, at 6:03 PM, Yung-Luen Lan wrote:
>
>> Ah, thanks! Maybe it's caused by WebObjects-FCGI adaptor or nginx.
>> I tried Apache2, seems don't have this kind of problem.
>
> I agree, it seems to be a bug in the adaptor.
>
>
>> Anyone use nginx w/ fcgi has the same issue?
>
> I am not using them
>
> Chuck
>
>
>> On Thu, Sep 16, 2010 at 8:25 AM, Chuck Hill <email@hidden> wrote:
>>> I'd expect that this is a bug in the WO Adaptor or in WO. It could possibly be a bug in Java or Apache, but that seems less likely. I'd suggest trying an update to WO 5.4.3 which has bug fixes for problems in 5.4.2.
>>>
>>> Chuck
>>>
>>>
>>> On Sep 15, 2010, at 4:14 PM, Yung-Luen Lan wrote:
>>>
>>>> Hi,
>>>>
>>>> The following code receives one chunk of multipart uploads and
>>>> appending it to a file.
>>>> (I have a client app which split the file first and then send the
>>>> chunks one by one.)
>>>> However, I got trouble when I deploy the code to a snow leopard
>>>> machine. I found the file uploaded is not the same as the original
>>>> file.
>>>>
>>>> It seems that if there is byte '\0' occurred in the upload stream, the
>>>> succeeding bytes all becomes zero.
>>>> But this code used to work on both my old server (10.5, WO 5.4.2, Java
>>>> 1.6 32bit) and dev machine (10.6, WO 5.4.2, Java 1.6 64bit)
>>>>
>>>> What could possibly get wrong?
>>>>
>>>> Regards,
>>>> yllan
>>>>
>>>> =====
>>>> try {
>>>> WORequest r = context().request();
>>>> WOMultipartIterator iterator = r.multipartIterator();
>>>> WOMultipartIterator.WOFormData data = null;
>>>> NSData fileData = null;
>>>>
>>>> while ((data = iterator.nextFormData()) != null) {
>>>> if (data.isFileUpload()) {
>>>> try {
>>>> InputStream stream = data.formDataInputStream();
>>>> fileData = new NSData(stream, 4096);
>>>> } catch (Exception e) {
>>>> return makeErrorXMLResponse(n, "UPLOAD: Failed to read Data from Stream.");
>>>> }
>>>> }
>>>> }
>>>>
>>>> if (fileData == null)
>>>> return makeErrorXMLResponse(n, "UPLOAD: Failed to read data from request.");
>>>>
>>>> fileData.writeToStream(session().pdfStream());
>>>> } catch (Exception e) {
>>>> return makeErrorXMLResponse(n, "UPLOAD: " + e.toString());
>>>> }
>>>> _______________________________________________
>>>> Do not post admin requests to the list. They will be ignored.
>>>> Webobjects-dev mailing list (email@hidden)
>>>> Help/Unsubscribe/Update your Subscription:
>>>>
>>>> This email sent to email@hidden
>>>
>>> --
>>> Chuck Hill Senior Consultant / VP Development
>>>
>>> Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
>>> http://www.global-village.net/products/practical_webobjects
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>
> --
> Chuck Hill Senior Consultant / VP Development
>
> Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
> http://www.global-village.net/products/practical_webobjects
>
>
>
>
>
>
>
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden