Multipart POST using NSInputStream subclass
Multipart POST using NSInputStream subclass
- Subject: Multipart POST using NSInputStream subclass
- From: Dave Dribin <email@hidden>
- Date: Tue, 15 May 2007 10:35:02 -0500
Hello,
I've been working on an NSInputStream subclass so I can POST a large
file without loading the entire file into memory. I'm currently
building the entire multipart/form-data body using NSMutableData, and
passing this to -[NSMutableURLRequest setHTTPBody:]. The downside to
this approach is that the entire HTTP body is resident in memory.
I noticed that the body of NSMutableURLRequest can alternately be set
using setHTTPBodyStream:. I figured if I can subclass NSInputStream,
I could achieve my goal. According to the NSInputStream doc [1], a
subclass needs to override three methods read:maxLength:,
getBuffer:length:, and hasBytesAvailable.
I've done this, and from my unit tests, it seems that I'm doing
everything correct. However, when I try to use my stream in an
NSURLConnection, I get the following runtime error:
*** -[DDMultipartInputStream _scheduleInCFRunLoop:forMode:]:
selector not recognized [self = 0x3062b0]
I found a message on the list from 2005 citing "problems with
subclassing
NSInputStream that may prevent it from working":
<http://lists.apple.com/archives/macnetworkprog/2005/Jul/
msg00004.html>
Is this still the case? Do I have to go the temporary file route?
Or am I just not subclassing NSInputStream correctly?
Thanks,
-Dave
[1]: http://developer.apple.com/documentation/Cocoa/Reference/
Foundation/Classes/NSInputStream_Class/Reference/Reference.html
_______________________________________________
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