JDjimenezdelgado / wtclient

Automatically exported from code.google.com/p/wtclient
0 stars 0 forks source link

Upload file problem #4

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
i can not upload file when using simulator 3.0, but version 2.2.1 is ok.
Pls help! Thanks in advance

Original issue reported on code.google.com by maigi...@gmail.com on 6 Oct 2009 at 11:16

GoogleCodeExporter commented 9 years ago
The reason: WTClient (delegate) did not automatically call the function 
"parserDidEndDocument", you need to 
add the following to call it manually: (file WTClient.m)
        [self parserDidEndDocument:xmlParser];

More detail:
- (void)HTTPConnection:(WTHTTPConnection *)connection 
didReceiveResponse:(NSDictionary *)response 
{
    self.currentResponse = response;
    if (connection == self.propertiesConnection) 
    {
        //get properties from response body and report about to delegate when finished
        NSXMLParser *xmlParser = [[[NSXMLParser alloc] initWithData:[response 
valueForKey:@"responseBody"]] autorelease];
        [xmlParser setDelegate:self];
        [xmlParser parse];
        [self parserDidEndDocument:xmlParser];
    }
    else if (connection == self.uploadConnection || connection == self.downloadConnection) 
    {
        if ([self.delegate respondsToSelector:@selector(transferClientDidFinishTransfer:)]) 
        {
            [self.delegate transferClientDidFinishTransfer:self];
        }   
    }
}

Regards,  :)
SonTH

Original comment by tranhoai...@gmail.com on 6 Oct 2009 at 2:20

GoogleCodeExporter commented 9 years ago
I just tried this in simulator 3.0 and it seems to work fine (at least with 
Mobile Me servers). 

parserDidEndDocument is called only when the XML was parsed successfully. If 
it's not called, that means an 
error occurred while parsing. Can you post an error message here 
(xmlParser.parserError)?

Probably the webdav server you are using generates some weird XML which does 
not get handled properly by 
NSXMLParser.

Original comment by alex.chu...@gmail.com on 7 Oct 2009 at 2:34

GoogleCodeExporter commented 9 years ago
i meet the same issue, after debug i found the reason is:
1. webdav server is HTTPS and need an authentication.
2. first time do preparePropertiesConnection, it failed at do authentication.
3. after finished authentication, the response for authentication is empty at 
responseBody.
So it will not call NSXMLParser  delegate parserDidEndDocument.

Original comment by bygree...@gmail.com on 7 Feb 2011 at 6:15