Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[che-dev] Outbound HTTP requests in Che server-side

Hi,

Currently, issuing outbound HTTP requests from server-side in Che is done mostly through HttpJsonHelper. I see several issues with both the design and implementation of the current approach.

First, it uses the method of Java URL streams. URL streams are more complicated to use and are very limited in terms of configuration and flexibility. I really think we should use the dedicated standard JAX-RS Client API.

Second, it has a static API which makes it practically impossible to intervene the connections. For example, system-wide client filters are very hard to apply elegantly. I think we should (gradually) move this to a centrally injection 'HTTP Cleint Provider' singleton.

Reiterating – JAX-RS Client API supports client filters and interceptors fluently.

Third, it is suitable for DTOs and strings only, although most of its core code is actually general and reusable. Other areas in the server code that need to issue HTTP requests with non-string/DTO responses, e.g. binary data, duplicate most parts of the code and use the response streams directly. This is harder to maintain and further worsens on the case of applying system-wide interceptions and configurations.

I would like to suggest, and assist in doing the change, gradually moving to centrally injected singleton that provides a pre-configured standard JAX-RS Client API client for general use. HttpJsonHelper would eventually be a centrally injected singleton too, reusing the described central HTTP client. I suggest doing it in steps:
1. Define a global 'client provider'
2. Gradually change code areas that duplicated the URL HTTP code to inject and use the central client
3. Temporarily having an 'injected' HttpJsonHelper that reuses the central client.
4. Gradually modify code areas that use legacy HttpJsonHelper to inject and use the new injectable HttpJsonHelper

I can further soften steps 3 and 4 by using assembly-level static injection to change the legacy HttpJsonHelper to use the central client.

Please share your thoughts on this.

thank you
Tareq Sharafy
Cloud Development Experience | SAP Labs Israel | 15 Hatidhar st, Raanana 43665, Israel
T +972-(0)7-4732-1647 | F +972-(0)9-777-5618

 


Back to the top