0

We have an middleware which generates a URL to download some files based on different type of request it receives. Now our middleware is deployed on windows environment. So while generating the url for appending the file path we are using the operating System's default path separator. For windows the default file path seprator is / i.e. backslash. If you want to know why file seprator for windows is / I have a nice blog for you here here.

So the url which gets generated usually looks likes the below url.

https://test.com:9000/elearning/filedownload?file-path=bulk\AssembledBDEFile1_1455748875242.xml

you can observer that after bulk keyword backslash are started because of the default file path separator.

This middleware is used by different third party applications. The problem is that the third party's are not accepting this url's they are saying, All of the communication is happening over web protocols so only forward slashes should be present and throwing an exception on use of \ . We are using OS default file separator because we want to make our middleware platform dependent.

We asked them to accept the url with combination of / and \ but they are not accepting our request saying \ are not part of web protocol.

So I just want to to know Is using \ is against web protocols and we are doing it in wrong way. Means we have to chnage our middleware or we should force themm to chnage their code.

Can anybody explain the role of \ in web protocols???

Nikhil Agrawal
  • 26,128
  • 21
  • 90
  • 126
  • 1
    Try to encode your parameters, see http://stackoverflow.com/questions/10786042/java-url-encoding-of-query-string-parameters – Arnaud Mar 14 '16 at 09:01

1 Answers1

2

The backslash \ is not an allowed character in URLs and therefore you need to apply percent-encoding and write it as %5C:

https://test.com:9000/elearning/filedownload?file-path=bulk%5CAssembled...
wero
  • 32,544
  • 3
  • 59
  • 84
  • If has to be done that way we can directly place / in place of \. Why to use even %5c???? – Nikhil Agrawal Mar 14 '16 at 09:04
  • @NikhilAgrawal if you want to include a backslash in a URL parameter you must encode it as `%5C`. That's all. Please read the wikipedia article. – wero Mar 14 '16 at 09:07
  • Java and Windows are very forgiving with qualified path names, you can use forward slashes and it'll still work, and then you don't have to do any tricks with embedding the backslash – Scott Sosna Mar 15 '16 at 00:15