New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting 'unexpected response' in ReportManager.m #113

Closed
donaldkwong opened this Issue Jun 22, 2011 · 4 comments

Comments

Projects
None yet
2 participants
@donaldkwong

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";
}

@donaldkwong

This comment has been minimized.

Show comment
Hide comment
@donaldkwong

donaldkwong Jun 22, 2011

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?

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?

@donaldkwong

This comment has been minimized.

Show comment
Hide comment
@donaldkwong

donaldkwong Jun 22, 2011

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, 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.

@donaldkwong

This comment has been minimized.

Show comment
Hide comment
@donaldkwong

donaldkwong Jun 22, 2011

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.

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 added a commit to lattejed/AppSales-Mobile that referenced this issue Jun 22, 2011

@donaldkwong

This comment has been minimized.

Show comment
Hide comment
@donaldkwong

donaldkwong Jun 22, 2011

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.

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.

evands pushed a commit that referenced this issue Jun 24, 2011

@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