Skip navigation.
 
mlGetting progress of HTTP POST as it's being UPLOADED
FROM : Daniel Kurtz
DATE : Tue Aug 29 22:52:17 2006

I need to get the status of a POST request as it's being uploaded. I need
this information so that I can display how many bytes have been uploaded so
far, and how many are left to be written.

I've gone as far as to use setHTTPBodyStream, subclassing
NSMutableURLRequest, then overriding the delegate method stream:handleEvent:
so I can track the progress of the stream that way. I did so because
NSURLRequest is supposed to set the delegate of the NSInputStream as itself,
according to the documentation. Even when I attempt this, it seems the
delegate method in my subclass is never called:

#import "VEMutableURLRequest.h"


@implementation VEMutableURLRequest

- (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)eventCode {

    NSLog(@"Stream Event!!");
}

- (void)setHTTPBodyStream:(NSInputStream *)inputStream {
    [super setHTTPBodyStream:inputStream];
    [[self HTTPBodyStream] setDelegate:self];
    NSLog(@"setHTTPBodyStream done");
    NSLog(@"delegate of Stream: %@", [[[self HTTPBodyStream] delegate]
className]);
}

@end

The console does show the log information for setHTTPBodyStream:, but it
does not show any log information for stream:handleEvent:. I am loading the
request this way:

NSURLResponse* response;
NSError* error;
NSData* result = [NSURLConnection sendSynchronousRequest:postRequest
returningResponse:&response error:&error];

The POST request is sent correctly, and there's no hitch in the
communication with the server. My only problem is that I can't seem to get
any delegate messages from the HTTPBodyStream.

Please, if anyone could please help me with this problem, I would really,
really appreciate it. Is this even possible with NSURLRequest? If not, how
would I go about doing so using a different framework (such as CURLHandle)?

Thanks in advance.

Daniel

Related mailsAuthorDate
mlGetting progress of HTTP POST as it's being UPLOADED Daniel Kurtz Aug 29, 22:52
mlRe: Getting progress of HTTP POST as it's being UPLOADED Gary Fielke Aug 30, 06:31
mlRe: Getting progress of HTTP POST as it's being UPLOADED Daniel Kurtz Aug 30, 08:59
mlRe: Getting progress of HTTP POST as it's being UPLOADED Gary Fielke Aug 30, 14:43
mlRe: Getting progress of HTTP POST as it's being UPLOADED Ferdinand Svehla Aug 30, 17:35