Skip to content

Commit

Permalink
Merge pull request #54 from ba-st/use_asAbsoluteUrl
Browse files Browse the repository at this point in the history
Avoid DNU when using an API client with a relative URL
  • Loading branch information
gcotelli authored Jun 16, 2022
2 parents 7f64b21 + 733fc9f commit a11caa6
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ CompositeHttpRequestCommandTest >> testApplyOn [
| httpClient command |

httpClient := ZnClient new.
command := CompositeHttpRequestCommand
ofAll:
(Array
with: (AddQueryStringFieldCommand named: 'fist_name' pairedTo: 'fran')
with: (AddQueryStringFieldCommand named: 'last_name' pairedTo: 'fox')).
command := CompositeHttpRequestCommand ofAll: ( Array
with: ( AddQueryStringFieldCommand named: 'first_name' pairedTo: 'fran' )
with: ( AddQueryStringFieldCommand named: 'last_name' pairedTo: 'fox' ) ).

command applyOn: httpClient.

self assert: httpClient request uri equals: '/?last_name=fox&fist_name=fran' asUrl
self assertUrl: httpClient request uri equals: '/?last_name=fox&first_name=fran'
]

{ #category : #tests }
Expand All @@ -27,10 +25,10 @@ CompositeHttpRequestCommandTest >> testShortcutCreation [
| httpClient command |

httpClient := ZnClient new.
command := (AddQueryStringFieldCommand named: 'fist_name' pairedTo: 'fran')
+ (AddQueryStringFieldCommand named: 'last_name' pairedTo: 'fox').
command := ( AddQueryStringFieldCommand named: 'first_name' pairedTo: 'fran' )
+ ( AddQueryStringFieldCommand named: 'last_name' pairedTo: 'fox' ).

command applyOn: httpClient.

self assert: httpClient request uri equals: '/?last_name=fox&fist_name=fran' asUrl
self assertUrl: httpClient request uri equals: '/?last_name=fox&first_name=fran'
]
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ RESTfulAPIClientIntegrationTest >> httpbinCacheLocation [
{ #category : #private }
RESTfulAPIClientIntegrationTest >> httpbinLocation [

^ 'http://localhost' asUrl
^ 'http://localhost' asAbsoluteUrl
]

{ #category : #private }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ RESTfulAPIClientTest >> jsonOkResponse [
{ #category : #private }
RESTfulAPIClientTest >> location [

^ 'http://localhost' asUrl + resourceIdentifier
^ 'http://localhost' asAbsoluteUrl + resourceIdentifier
]

{ #category : #tests }
Expand Down
2 changes: 1 addition & 1 deletion source/Superluminal-RESTfulAPI/RESTfulAPIClient.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ RESTfulAPIClient >> clientErrorMessageFrom: response [
RESTfulAPIClient >> clientPoolFor: aLocation [

^ httpClientPoolByAuthority
at: aLocation asUrl authorityWithPort
at: aLocation asAbsoluteUrl authorityWithPort
ifAbsentPut: [ OPBasicPool new
creator: httpClientProvider;
destroyer: #close;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Class {
}

{ #category : #accessing }
ConsulAgentHttpAPIBasedDiscoveryClientTest >> consulAgentLocation [
ConsulAgentHttpAPIBasedDiscoveryClientTest >> consulAgentLocation [

^ 'http://localhost' asUrl port: port
^ 'http://localhost' asAbsoluteUrl port: port
]

{ #category : #running }
Expand Down

0 comments on commit a11caa6

Please sign in to comment.