RobertoMalatesta / jsc3d

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

HTTP's 412 (Precondition Failed) handling for .obj and .mtl files #129

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Init sample object on a page running on an iPad's Safari with iOS 8.0 or 
8.1.1
2. Then reinit object without refreshing the page
3. It was tested on Apache 2.2.+

What is the expected output? What do you see instead?
After reinit 3d objects can't be loaded properly.

What version of the product are you using? On what operating system?
Safari, iPad, iOS 8.0 or 8.1.1, Apache 2.2.+

Please provide any additional information below.
jsc3d uses XMLHTTPRequest's POST method for loading static files. After second 
use of the same 3d model without refreshing a page, browser tries to use a 
cached version of the file and receives 412 status from the server so the 
library can't load the files properly. According to RFC 2616 which is a 
specification for HTTP/1.1 protocol http://www.ietf.org/rfc/rfc2616.txt 
receving 412 status seems to be ok when http client tries to use a cache of the 
content with the POST method and it is a counterpart of 304 Not Modified status 
for GET method. In my opinion the library should also handle 412 status by 
trying to load a file in the next attempt by using GET method or every time 
while loading obj/mtl files with POST should add some random variable (e.g. 
timestamp) to their urls. It can also use GET instead of POST.
Of course the problem could be fixed by not attaching the HTTP's ETag header 
(which is used for caching) by the server sending obj/mtl files or by not 
initializing the same 3d objects more than once without refreshing the page. 
But I use a 3rd-party software which uses jsc3d library in that manner so it is 
not the case to fix this there.

Original issue reported on code.google.com by kamilka....@gmail.com on 26 Nov 2014 at 12:13

GoogleCodeExporter commented 9 years ago
Really thanks for submitting this issue! I haven't encountered such a problem 
before.  Then, is there a fast way to reproduce this error? Shall I make any 
special
configuration to my HTTP server?

Original comment by Humu2...@gmail.com on 26 Nov 2014 at 1:18

GoogleCodeExporter commented 9 years ago
I'm really suprised with such a quick response :)
I don't know exactly what headers Safari sends beacuse standard Safari debugger 
on Mac seems like not telling the whole truth about headers but I think it can 
be emulated by adding some additional headers to ajax request, such as 
If-None-Match with the same value as ETag header from the first Response. At 
least I could have emulated that by using Advanced Rest Client in Chrome.

Original comment by kamilka....@gmail.com on 26 Nov 2014 at 2:29

GoogleCodeExporter commented 9 years ago
I just checked the source code. It seems there's no POST method used. All the 
file requests are through GET method. See 
http://code.google.com/p/jsc3d/source/browse/trunk/jsc3d/jsc3d.js#5075 for 
example. I guess the copy you are using may be a modified version of this 
library.  

Anyway I'll google these keywords to see if I can find some useful information 
on this topic.

Original comment by Humu2...@gmail.com on 26 Nov 2014 at 3:29

GoogleCodeExporter commented 9 years ago
Yes, you're right. I took for granted that the library I have is original and 
without any modifications but it seems that it was spoiled. So, anyway sorry 
for wasting your time.

Original comment by kamilka....@gmail.com on 27 Nov 2014 at 6:31

GoogleCodeExporter commented 9 years ago
I guess you could check out the latest edition from the repository and see 
whether it works correctly in your project :-)

Original comment by Humu2...@gmail.com on 27 Nov 2014 at 7:54