-
Notifications
You must be signed in to change notification settings - Fork 255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: stop method
property from being mandatory for push http transfers
#3797
fix: stop method
property from being mandatory for push http transfers
#3797
Conversation
@@ -53,7 +53,7 @@ public HttpRequestParams.Builder decorate(DataFlowRequest request, HttpDataAddre | |||
} | |||
|
|||
private @NotNull String extractMethod(HttpDataAddress address, DataFlowRequest request) { | |||
if (Boolean.parseBoolean(address.getProxyMethod())) { | |||
if (Boolean.parseBoolean(address.getProxyMethod()) && "HttpProxy".equals(request.getDestinationDataAddress().getType())) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't expect that this will solve the issue regarding the HttpPush
. This will disable the feature of proxying http methods for the HttpPush
, as now just "GET" requests will be sent to the providing backend.
Our expectation would be that http-methods also could be proxied for the HttpPush
. We could also help providing this fix, if this is more convenient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simply, for http push this condition won't ever met, and it will pass through line 60, so the method
will be taken from the DataAddress
(as it already does) if it's defined, otherwise it will use the default GET
.
To verify that, just try to remove the proxyMethod
property and set method
instead on the source data address.
The proxy was made to work with pull
, not for push
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simply, for http push this condition won't ever met, and it will pass through line 60, so the method will be taken from the DataAddress (as it already does) if it's defined, otherwise it will use the default GET.
Ohh yes, I have overlooked this: The HttpPush
will use the method
from the DataAddress
.
The proxy was made to work with pull, not for push
This would implicate that certain HttpData
assets can just be used for HttpProxy
transfer-types and not for HttpData
transfer-types. However it would make sense to also support this for the HttpPush
.
So basically this would be a feature request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
theoretically yes, I'm not sure which would be the applications for that: the consumer should be the one who chose how the call to its service will be made.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The applications would be the same as for the http-pull
I think.
So for the http-pull
the consumer
is able to select the preferred http-method, which is used to access the provider
system. This is enabled by using the prxoyMethod=true
property in the asset of the provider.
For the http-push
the transfer is also started by the consumer
. Like for the http-pull
the consumer
should be able to select the prefered http-method, which is used to access the provider
system.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in any case, also without the proxyMethod
flag to true, the consumer can choose the method, that by default is GET
. Really, all the proxyXXX
stuff is there for the proxy
use case ("nomen omen").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ndr-brt,
I'm sry for coming back on this so lately, but this change is really important to us and I may not have understood this correctly.
After giving this a second look, I am also convinced, that this change won't affect passing methods for the HttpPush
from the consumer.
My problem was, that I though the HttpDataAddress address
parameter is always populated by the SourceDataAddress
:
Lines 55 to 61 in cf629c9
private @NotNull String extractMethod(HttpDataAddress address, DataFlowStartMessage request) { | |
if (Boolean.parseBoolean(address.getProxyMethod()) && "HttpProxy".equals(request.getDestinationDataAddress().getType())) { | |
return Optional.ofNullable(request.getProperties().get(METHOD)) | |
.orElseThrow(() -> new EdcException(format("DataFlowRequest %s: 'method' property is missing", request.getId()))); | |
} | |
return Optional.ofNullable(address.getMethod()).orElse(DEFAULT_METHOD); | |
} |
but it turns out it also gets called for the DestinationDataAddress
:
Lines 54 to 68 in cf629c9
@Override | |
public HttpRequestParams provideSourceParams(DataFlowStartMessage request) { | |
var params = HttpRequestParams.Builder.newInstance(); | |
var address = HttpDataAddress.Builder.newInstance().copyFrom(request.getSourceDataAddress()).build(); | |
sourceDecorators.forEach(decorator -> decorator.decorate(request, address, params)); | |
return params.build(); | |
} | |
@Override | |
public HttpRequestParams provideSinkParams(DataFlowStartMessage request) { | |
var params = HttpRequestParams.Builder.newInstance(); | |
var address = HttpDataAddress.Builder.newInstance().copyFrom(request.getDestinationDataAddress()).build(); | |
sinkDecorators.forEach(decorator -> decorator.decorate(request, address, params)); | |
return params.build(); | |
} |
So indeed the extractMethod
returns the method specified by the DestinationDataAddress
.
Did I understood this correctly?
Thanks for fixing this!
What this PR changes/adds
The
method
property was mandatory when theproxyMethod
was true, but, in fact, also if a sourceDataAddress
defines that property, it could be that the same asset is used in aPUSH
type transfer, this fix permits to do that by adding an additional check.Why it does that
fix bug
Further notes
transferType
field that will be mandatory, while thedataDestination
won't be supplied forpull
transfers.Linked Issue(s)
Closes #3768
Please be sure to take a look at the contributing guidelines and our etiquette for pull requests.