
Hi, Is there any means of controlling the HTTP headers Oxygen sends when using 'Open URL' from the File menu? I'm working with an API that uses Accept headers to return different subsets of a large document, and it'd be very useful to be able to control that within Oxygen too. Thanks! Cambridge University Press is the publishing business of the University of Cambridge with VAT registered number GB 823 8476 09. Our principal office is at University Printing House, Shaftesbury Road, Cambridge, CB2 8BS, United Kingdom.

On 19/12/2015 1:41 am, Tom Cleghorn wrote:
Hi,
Is there any means of controlling the HTTP headers Oxygen sends when using 'Open URL' from the File menu? I'm working with an API that uses Accept headers to return different subsets of a large document, and it'd be very useful to be able to control that within Oxygen too.
Off the top of my head, I'm not sure, but oXygen uses Apache's HttpClient so if there's a way to do it directly with that (probably) then you can probably tweak the built-in version(s) the same way. Expect to be fiddling with its innards directly, though, rather than using the GUI to set the headers. That, however is just if using the file menu method is a requirement for your writers. If it's not and it's just about opening connections by whatever method you like (e.g. a plugin pr external application call) then there's plenty of alternative methods, particularly if you're using an operating system with libcurl installed, for example. My weapon of choice if it had to be platform independent would be: external application call, plus Jython 2.7 (full 100MB install), plus the requests python module, plus oXygen API call to open the file when it finished downloading. Why? Because requests makes HTTP calls pleasant (and you can load your preconfigured headers, proxies and other parameters as a python dict ... or JSON. Oh, I've already checked, requests installs with Jython just fine. If it were just for me, though, I'd skip the Jython part and use the system install of either libcurl or Python 3.5 with requests. Probably the Python method because I've got plenty of similar stuff already using requests to share code with. Including bits to access the Tor network with it (most of my Twython delivered tweets end up going through that method, just to annoy the national surveillance systems weenies these days, but originally for the more traditional reason: to see if it would work). Regards, Ben

Hi all, A solution to control the HTTP headers is to implement a custom protocol plugin. This plugin allows you to create your own URLConnection for an URL with a custom protocol other than the protocols handled by oXygen: file, http, https, ftp or ftps. When you are asked for an URLConnection, you can create a HTTPURLConnection which has API for setting custom headers. If you want to use the HTTPConnection that oXygen uses, you have to instantiate the ro.sync.net.protocol.http.WebdavHttpURLConnection class. One of the advantages of using this class is that it is aware of the proxy options that are set in oXygen. So, this solution implies that you will use a custom protocol when you want to access your files ( for instance cproto://host.com/dir1/dir2/file.xml). For this protocol, you will be asked for an implementation of URLConnection that allows you to set custom headers. More about custom protocol plugin extension: https://www.oxygenxml.com/doc/versions/17.1/ug-editor/index.html#concepts/cu... However, it is possible to impose a custom URL stream handler for the http protocol. This can be done through the 'Targeted URL Stream Handler' plugin. See more details here: https://www.oxygenxml.com/doc/versions/17.1/ug-editor/index.html#concepts/ta... Regards, Radu -- Radu Pisoi <oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger http://www.oxygenxml.com On 12/18/2015 4:41 PM, Tom Cleghorn wrote:
Hi,
Is there any means of controlling the HTTP headers Oxygen sends when using 'Open URL' from the File menu? I'm working with an API that uses Accept headers to return different subsets of a large document, and it'd be very useful to be able to control that within Oxygen too.
Thanks!
Cambridge University Press is the publishing business of the University of Cambridge with VAT registered number GB 823 8476 09. Our principal office is at University Printing House, Shaftesbury Road, Cambridge, CB2 8BS, United Kingdom. _______________________________________________ oXygen-user mailing list oXygen-user@oxygenxml.com https://www.oxygenxml.com/mailman/listinfo/oxygen-user
participants (3)
-
Ben McGinnes
-
Radu Pisoi
-
Tom Cleghorn