Malandrain
Malandrain

Reputation: 91

HTTP GET request to get binary content of an XML file

I'm trying to get the binary content of an XML file through HTTP but the server just want to give me kind of interpreted format (wich removes \r for every \r\n).

My HTTP GET request is simple : "GET http://%s%s%s HTTP/1.0\r\nConnection: Keep-Alive\r\n\r\n"

It works for extention except .xml. And if I change the .xml in .notxml, it works.

So, I'm looking for a way to the binary content without any change in the file.

Thank you in advance.

Upvotes: 4

Views: 1108

Answers (3)

Malandrain
Malandrain

Reputation: 91

It was caused by my FTP Client (FileZilla). If I transfer .nxml and rename in .xml by FTP, the file is OK. Thanks for trying to help me.

Upvotes: 1

Brandon Moretz
Brandon Moretz

Reputation: 7641

This is almost definitely a Mime-Type issue. If you're using IIS I would suggest checking out:

http://technet.microsoft.com/en-us/library/bb742440.aspx

Upvotes: 1

Jim Garrison
Jim Garrison

Reputation: 86774

The problem is on the server. When you ask it for an XML file it looks in a table that maps extensions to Mime-Types. In the default case, the mime-type for XML is either text/xml or application/xml, both of which are considered text formats and subject to line-ending translation. To get a binary stream for XML you have to find a way to force the server to treat it as binary instead of text. This means changing the server configuration or using a different extension that is treated as binary.

Upvotes: 1

Related Questions