Re: Multipart POST using NSInputStream subclass
Re: Multipart POST using NSInputStream subclass
- Subject: Re: Multipart POST using NSInputStream subclass
- From: Dave Dribin <email@hidden>
- Date: Wed, 16 May 2007 10:35:02 -0500
On May 15, 2007, at 11:16 AM, Quinn wrote:
A while back I researched this topic independently of the above-
mentioned incident. My conclusion was that it was not possible to
implement an asynchronous stream (that is, a stream that can be
scheduled on the runloop, which is a requirement for any CFNetwork
use) by subclassing NSInputStream without implementing a number of
undocumented methods. _scheduleInCFRunLoop:forMode: is one of
these methods.
Having access to the source (-: I was able to implement these
methods and get my code to work. However, I won't make my code
public because I can't, in good faith, encourage folks to go
overriding undocumented methods.
Thanks for looking into this. After more Google searching last
night, I found some code that overrode some private methods in an
NSInputStream subclass:
<http://svn.toxicsoftware.com/public/trunk/Frameworks/
ToxicCrashCatcher/CrashReporter/Source/Utilities/
CMultipartFormDataInputStream.m>
With this info, I was able to get my NSInputStream subclass to work
by providing the following stub methods:
- (void) _scheduleInCFRunLoop: (NSRunLoop *) inRunLoop forMode: (id)
inMode
{
// Safe to ignore this?
}
- (void) _setCFClientFlags: (CFOptionFlags)inFlags
callback: (CFReadStreamClientCallBack) inCallback
context: (CFStreamClientContext) inContext
{
// Safe to ignore this?
}
Of course, I don't know if it is actually safe to ignore these
methods. Is this something you can comment on? Will this break in
some weird way because I'm not providing an actual implementation to
these methods?
Thus, your options are:
1. safe but inefficient -- Create a temporary file and using a file
stream.
Well, at least it's memory efficient, right?
Nor could I find any bugs requesting a public API for implementing
a custom CFStream.
Is a custom CFStream needed? Also in my investigation yesterday, I
looked at how WebKit handles multipart forms. I found
FormDataStreamCFNet.cpp:
<http://trac.webkit.org/projects/webkit/browser/trunk/WebCore/
platform/network/cf/FormDataStreamCFNet.cpp>
This seems to provide a read stream with custom callbacks. Is this
using quasi-private APIs? Or could could I try this technique, using
the callbacks to get back into Obj-C land?
OTOH, we do have a bug requesting that we make NSStream subclasses
play nice with CF (<rdar://problem/3222783>).
Should I create a bug that specifically mentions NSMutableURLRequest
and NSInputStream subclasses not playing nice?
-Dave
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden