Skip to content

Getting 'unexpected response' in ReportManager.m #113

donaldkwong opened this Issue Jun 22, 2011 · 4 comments

2 participants


Downloading reports started failing today in downloadReport. For some reason, my headers don't contain either 'Filename' or 'filename', so it fails with 'unexpected response'. Here is a dump of the headers, if it helps:

(gdb) po [downloadResponse allHeaderFields]
"Cache-Control" = private;
"Content-Encoding" = gzip;
"Content-Language" = "en-US";
"Content-Type" = "text/html;charset=ISO-8859-1";
Date = "Wed, 22 Jun 2011 06:06:25 GMT";
Server = "Apache-Coyote/1.1";
"Transfer-Encoding" = Identity;
"X-Powered-By" = "JSF/1.2";


Did more debugging and noticed that the HTTP POST in downloadReport isn't getting the CSV data, it's getting the Sales and Trends page. What's going on?


OK, figured out the problem. I needed to add the following POST field into the first dictionary in downloadReport:

                          @"theForm:j_id_jsp_60478444_43", @"theForm:j_id_jsp_60478444_43",

Not sure if anyone else is running into this problem.


OK, found the source of the bug. In fetchReportsWithUserInfo:, the lines:

NSString *weeklyName = [dailyName stringByReplacingOccurrencesOfString:@"_6" withString:@"_22"];
NSString *ajaxName = [dailyName stringByReplacingOccurrencesOfString:@"_6" withString:@"_2"];
NSString *daySelectName = [dailyName stringByReplacingOccurrencesOfString:@"_6" withString:@"_43"];
NSString *weekSelectName = [dailyName stringByReplacingOccurrencesOfString:@"_6" withString:@"_48"];

are bad, because my dailyName is 'theForm:j_id_jsp_60478444_6'. These lines will replace BOTH occurrences of '_6' when the intention is to only replace the final occurrence. We should probably restrict the string replace with a range of just the final two characters of the string.

@lattejed lattejed added a commit to lattejed/AppSales-Mobile that referenced this issue Jun 22, 2011
@lattejed lattejed Added fix for issues #112 & #113 62d4c60

Awesome, thanks. We can probably clean that up a bit more by using stringByReplacingCharactersInRange:withString:
instead of stringByReplacingOccurrencesOfString:withString:options:range: since we know that the entire range needs to be replaced.

@omz omz closed this Aug 3, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.