[Grub-dev] Possible cause for windows 401 errors

chris hall followingthepath at gmail.com
Mon Jan 19 20:30:36 UTC 2009


I mentioned in "Re: [Grub-dev] Small error in protocol definition" about the
error I think is causing my problems I was having in
http://grub.org/?q=en/node/237
Where every uploaded arc file received a 401 error.
I thought it best to start a new conversation as the old topic has nothing
to do with this, I appologise for double posting.

But to sum up:
Grub using "w" mode (write) for opening an arc file, which means it opens it
in text mode. Which also means it uses the operating systems newline
character. So in grub when a arcfile is written as
"im arcfile data\n"
and then counted, what it is really written as is
"im arcfile data\r\n"
which means the count is now off by 1 byte.

This is only apparent in windows (and maybe mac?).
Whenever you open a file in text mode in python (on windows) all the
occurances of \r\n automatically get translated to \n

This could furthur cause problems as the server itself is not implimented in
python, perl I think, In which case this automatic translation of \r\n does
not occur.
The client (python) count of 16 for
"im arcfile data\n"
and the server (perl) count of 17 for
"im arcfile data\r\n"
do not match and a 401 (invalid arcfile) error is returned.

This only explains some of the 401 erros, as I occasionally get 401 errors
on my linux system in which this cannot be the case.

A simple solution to this is to open the arcfile in write binary mode, or
"wb" in which case the file is not translated at all. Ie when the client
writes a \n it is actually written as a \n

This will not change the functionality on Linux or Unix systems whatsoever


Yet again I appologise greatly for double posting, but did so incase a
developer was to not read the previous post and as I should not have posted
it there in the first place, but at 12am I was not thinking. Sorry.
Hope this is clear enough,
Chris.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wikia.com/pipermail/grub-dev/attachments/20090119/0d432480/attachment.html 


More information about the Grub-dev mailing list