@@ -23,6 +23,7 @@ class Client
2323 attr_accessor :fhir_version
2424 attr_accessor :cached_capability_statement
2525 attr_accessor :additional_headers
26+ attr_accessor :proxy
2627 attr_accessor :exception_class
2728
2829 # Call method to initialize FHIR client. This method must be invoked
@@ -32,13 +33,14 @@ class Client
3233 # @param default_format Default Format Mime type
3334 # @return
3435 #
35- def initialize ( base_service_url , default_format : FHIR ::Formats ::ResourceFormat ::RESOURCE_XML )
36+ def initialize ( base_service_url , default_format : FHIR ::Formats ::ResourceFormat ::RESOURCE_XML , proxy : nil )
3637 @base_service_url = base_service_url
3738 FHIR . logger . info "Initializing client with #{ @base_service_url } "
3839 @use_format_param = false
3940 @exception_class = ClientException
4041 @default_format = default_format
4142 @fhir_version = :stu3
43+ @proxy = proxy
4244 set_no_auth
4345 end
4446
@@ -104,6 +106,8 @@ def set_no_auth
104106 @use_basic_auth = false
105107 @security_headers = { }
106108 @client = RestClient
109+ @client . proxy = proxy unless proxy . nil?
110+ @client
107111 end
108112
109113 # Set the client to use HTTP Basic Authentication
@@ -115,6 +119,8 @@ def set_basic_auth(client, secret)
115119 @use_oauth2_auth = false
116120 @use_basic_auth = true
117121 @client = RestClient
122+ @client . proxy = proxy unless proxy . nil?
123+ @client
118124 end
119125
120126 # Set the client to use Bearer Token Authentication
@@ -125,6 +131,8 @@ def set_bearer_token(token)
125131 @use_oauth2_auth = false
126132 @use_basic_auth = true
127133 @client = RestClient
134+ @client . proxy = proxy unless proxy . nil?
135+ @client
128136 end
129137
130138 # Set the client to use OpenID Connect OAuth2 Authentication
@@ -144,6 +152,7 @@ def set_oauth2_auth(client, secret, authorize_path, token_path, site = nil)
144152 raise_errors : true
145153 }
146154 client = OAuth2 ::Client . new ( client , secret , options )
155+ client . connection . proxy ( proxy ) unless proxy . nil?
147156 @client = client . client_credentials . get_token
148157 end
149158
0 commit comments