0

I'm working on a project in which my server API was not designed to use HTTP to send and receive information from clients. Instead, it uses a custom-made protocol, with its own format, encoding and compression algorithms (obviously not supported by modern browsers).

I'm thinking about developing a web application to interact with the server, so I was wondering if there's a way to make a dynamic asynchronously request with JavaScript without following the HTTP standard and then parse all requests and responses myself using JavaScript.

I tried looking up on normal AJAX (XMLHttpRequest) and even came across this question, but after reading the reference on the function I quickly discovered that not only there are parameters that you cannot change, but you can't delete elements such as the header itself (METHOD Resource HTTP/1.1, etc.).

That being the case, I would like to confirm if there's absolutely no way of interacting with the API as it is with a web application.

Thanks in advance.

joaop
  • 75
  • 1
  • 12
  • Provide details on the "custom" protocol. – cybersam Dec 15 '17 at 19:54
  • It is really a sequence of binary digits. The first two bits of first byte received indicate the current authentication status of the user, the next two the action (kind of equivalent to the HTTP Method), and the next four the target object. After that it really depends a lot on the action. – joaop Dec 15 '17 at 19:56
  • 2
    I seriously, seriously doubt this is possible, due to built in security policies in the browser, the same reason that you can't modify certain HTTP headers. If you could specify an arbitrary sequence of binary then you'd be able to get around the HTTP restrictions by basically reimplementing HTTP with circumventions. – jered Dec 15 '17 at 20:00
  • You could always just create your own browser to handle this specific protocol. But you know, that might take... years. – Bilbo Baggins Dec 15 '17 at 20:07
  • @BilboBaggins Actually I think I will rewrite the server to ignore everything in a request up until a control character and then just process the request from there. That way it will still be backwards compatible. – joaop Dec 15 '17 at 20:13
  • 1
    You may try to write a custom web app to handle the non-http protocol that you are describing. Check this Mozilla MDN article: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/registerProtocolHandler/Web-based_protocol_handlers. – M. F. Dec 15 '17 at 20:48
  • @M.F. That was very interesting, but it would be bothersome to ask users for confirmation. Thanks though, didn't know this was possible, it might be useful in the future. – joaop Dec 15 '17 at 21:10

0 Answers0