-
Notifications
You must be signed in to change notification settings - Fork 117
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
Mis-interpretation of what is being transmitted by a remote httpclient request... #129
Comments
Can you provide some sample code for me to use to debug? All you've said so far is that when you make a request with Titanium it goes through a different code path -- but you haven't said how you're making that request.
I can't move forward without these types of details. The more you can provide, the better. |
Hi Adam, Thanks for the quick response. I am glad to provide any detail you may require. First, however, let me point out that I have verified that this issue is the very same as #125. After I posted my issue, I went back to my code and put in the "Accept" header as #125 said they had to do. IT WORKED!! Now...here is the detail... Any of the following URLs should return the json data provided by my site which was based on your "jsonutil" example: If you key any of these into any browser your coldfusion json data spits back as expected. Now, it did not in my mobile app which of the following nature: PLATFORM: Appcelerator Titanium 3.0 which is an Eclipse based IDE that ports code to Android/iOS/MobileWeb from a single project codebase. LANGUAGE: Javascript Here is a simple version of the code that did NOT work:
The following modification also DID NOT Work:
The following modification ACTUALLY DID WORK:
While I am thrilled to get it working, there probably still is the remaining issue of whether this is a Taffy bug. I can say this: after nearly 4 days of googling and researching, I could not find one example elsewhere where the "Accept" header was required as a general matter when making HTTPClient calls with Ti for JSON, XML, or otherwise. For my part, it doesn't matter because I have found a workaround. However, for your part, it may behoove you to see if there is a way you can handle a request without that header in case someone else runs into what I did. Thanks for developing this cool framework! |
Oh, in answer to your third question, there is no jQuery in my code and I am not certain that Ti supports it although I did see some community discussion of that. |
Thanks for providing all of your code samples and answering my questions so thoroughly, this is very helpful. I can confirm that this does indeed look like a bug. The reason your requests work in the browser is that the browser includes the Accept header when you make a request (usually set to some variant of "text/html" because that's what browsers want to display)... Another work-around would be to specify the format on the URL, like so:
Note that I've added Nevertheless, this is definitely a bug. I will see about getting it fixed for the impending 1.3 release. Thanks again for all of your effort and detail in reporting! |
Another way to test this is using Railo (my version is 3.3.4.003 final) with the tag cfhttp. It is creating a request without "Accept" header. I did some additional debugging and found out that the key "application._taffy.settings.defaultMime" is holding the extension of the default mime type, so it should be checked against the supported extensions instead the supported mime types. Change line 520 to the following fixes the problem:
Or event better is using function "mimeSupported" that, according the name, should check this correctly |
Resolved by #132 |
I have found a bug in the API.CFG. It is in the section of the code in line 520s area where it is determining which mime type is being used (presumably to determine the function to call).
Background:
I am using Appcelerator Titanium 3.0 to build mobile apps because it is great for having one codebase for my mobile app but can port to 1) Android 2) iOS or 3) MobileWeb.
Here is the symptom of the problem:
Well, obviously the Titanium HTTPClient calls to Taffy are not supplying exactly the same info that occurs when a user submits the very SAME URL into a browser.
I explored for 3 days all the different special idiosyncrasies of any platform involved including the server, the server software, Titanium, etc.
Then, I decided to GREP all of the places in the CORE that had 400 just to see if Taffy was initiating the problem. I found about 7 or 8 places. So I iteratively went through and changed each one to 403 to see if the remote call from the mobile device would get a 403 instead of a 400. Low and behold it did and here is the place in the code where it occurs:
FILE: API.CFG
CONCLUSION:
the API.CFG claims that the "Your default mime type (#application._taffy.settings.defaultMime#) is not implemented". But would not that same fact be true whether regardless from where I submitted the URL? I believe there is a mismatch perhaps in the logic between the mimeType and mimeEXT.
Of course, I did not dig any deeper to determine what is different about what is being delivered to Taffy from a browser versus the mobile app httpclient. However, I suspect you all might be able to figure it out and let me know.
WHAT I DID AS A WORKAROUND FOR NOW:
I remarked out the code that claims the defaultMime is not implemented and just forced it to return "json" because that was the value of #application._taffy.settings.defaultMime#.
The text was updated successfully, but these errors were encountered: