{"issue":{"created_at":"2011-06-02T10:37:27Z","state":"open","updated_at":"2011-11-21T11:01:23Z","comments":5,"user":{"gravatar_id":"de1ec7a0e3288c451f500a6f333d35ca","id":558050,"url":"https://api.github.com/users/jayztemplier","login":"jayztemplier","avatar_url":"https://secure.gravatar.com/avatar/de1ec7a0e3288c451f500a6f333d35ca?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"Hi, \r\nI spend hours to detect an error : I try to upload an image from the iPhone to my RoR server. The time out is set to 10. \r\nThe server receive datas, and respond well, but ASI detects a Time out even when the image has been uploaded. So I tried to read ASIHTTPRequest.m and I found this (I added nslog):\r\n\r\n- (BOOL)shouldTimeOut\r\n{\r\n\tNSTimeInterval secondsSinceLastActivity = [[NSDate date] timeIntervalSinceDate:lastActivityTime];\r\n\t// See if we need to timeout\r\n\tif ([self readStream] && [self readStreamIsScheduled] && [self lastActivityTime] && [self timeOutSeconds] > 0 && secondsSinceLastActivity > [self timeOutSeconds]) {\r\n\t\t\r\n\t\t// We have no body, or we've sent more than the upload buffer size,so we can safely time out here\r\n\t\tNSLog(@\"postLenght(%ld) - sent(%ld) - bufferSize(%ld)\",[self postLength], [self totalBytesSent],[self uploadBufferSize]);\r\n\t\tif ([self postLength] == 0 || ([self uploadBufferSize] > 0 && [self totalBytesSent] > [self uploadBufferSize])) {\r\n\t\t\treturn YES;\r\n\t\t\t\r\n\t\t// ***Black magic warning***\r\n\t\t// We have a body, but we've taken longer than timeOutSeconds to upload the first small chunk of data\r\n\t\t// Since there's no reliable way to track upload progress for the first 32KB (iPhone) or 128KB (Mac) with CFNetwork, we'll be slightly more forgiving on the timeout, as there's a strong chance our connection is just very slow.\r\n\t\t} else if (secondsSinceLastActivity > [self timeOutSeconds]*1.5) {\r\n\t\t\treturn YES;\r\n\t\t}\r\n\t}\r\n\treturn NO;\r\n}\r\n\r\nand here are the logs of the Console :\r\npostLenght(167649) - sent(0) - bufferSize(167649)\r\npostLenght(167649) - sent(0) - bufferSize(167649)\r\npostLenght(167649) - sent(0) - bufferSize(167649)\r\npostLenght(167649) - sent(0) - bufferSize(167649)\r\npostLenght(167649) - sent(0) - bufferSize(167649)\r\n postLenght(167649) - sent(0) - bufferSize(167649)\r\npostLenght(167649) - sent(0) - bufferSize(167649)\r\n postLenght(167649) - sent(0) - bufferSize(167649)\r\n\r\nand sometimes I had :\r\n\r\n postLenght(167649) - sent(167649) - bufferSize(0)\r\npostLenght(167649) - sent(167649) - bufferSize(0)\r\n postLenght(167649) - sent(167649) - bufferSize(0)\r\n\r\nIn those two cases, ASI returns YES to the shouldTimeOut, but the server received my image and other datas ...\r\n\r\nMy temporary solution is to comment a part of the predicat :\r\n\t\tif ([self postLength] == 0 /* || ([self uploadBufferSize] > 0 && [self totalBytesSent] > [self uploadBufferSize])*/) {\r\n\t\t\treturn YES;\r\n\r\nBut if you have another solution, I'll take it :)\r\n\r\nThank you","assignee":null,"id":989332,"labels":[],"number":202,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"title":"Upload Image and Time Out","closed_at":null,"html_url":"https://github.com/pokeb/asi-http-request/issues/202","url":"https://api.github.com/repos/pokeb/asi-http-request/issues/202","milestone":null},"action":"created","comment":{"created_at":"2011-11-21T11:01:23Z","updated_at":"2011-11-21T11:01:23Z","user":{"gravatar_id":"847cb754fbd710f4be4d21bf09b2efd1","id":39792,"url":"https://api.github.com/users/Gurpartap","login":"Gurpartap","avatar_url":"https://secure.gravatar.com/avatar/847cb754fbd710f4be4d21bf09b2efd1?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"body":"![ASIHTTPRequest Timeout](http://cl.ly/103l0c2V2J0F2C0n2q24/Screen%20Shot%202011-11-21%20at%204.27.53%20PM.png)","id":2813877,"url":"https://api.github.com/repos/pokeb/asi-http-request/issues/comments/2813877"}}