Skip to content
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

Extend HttpOpener. #463

Merged
merged 12 commits into from
Sep 8, 2022
Merged

Extend HttpOpener. #463

merged 12 commits into from
Sep 8, 2022

Conversation

dr0i
Copy link
Member

@dr0i dr0i commented Aug 29, 2022

Resolves #460.

Copy link
Member

@blackwinter blackwinter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely requires (better) documentation and tests before we can proceed!

- add */* as content type default
@dr0i
Copy link
Member Author

dr0i commented Aug 29, 2022

re "tests":
we didn't have these before. Are they really necessary? Could you go on provide those?

@blackwinter
Copy link
Member

we didn't have these before. Are they really necessary?

Exactly. And I honestly don't think that's a good argument ;) The functionality is getting more complex and we should have at least some test coverage.

Could you go on provide those?

Yes, I could, but probably not too soon.

@dr0i
Copy link
Member Author

dr0i commented Aug 29, 2022

I know the following is also not a good excuse - but can we merge this already because we have some issues to solve?
Tests would be only postponed - promised!

@blackwinter
Copy link
Member

I know the following is also not a good excuse - but can we merge this already because we have some issues to solve?

Of course, I don't want to hold back progress. But we shouldn't rush anything prematurely, either. Are you sure that the design is sound? Do others want to chime in? I mean, there were some concerns regarding complexity and reusability. (Will you change the content-type default handling?)

How would this be consumed, anyway? Are you going to publish a new release?

Tests would be only postponed - promised!

Haven't we all heard that one a thousand times? ;)

@dr0i
Copy link
Member Author

dr0i commented Aug 29, 2022

How would this be consumed, anyway? Are you going to publish a new release?

Would be the basis for #464 and that one to solve https://gitlab.com/oersi/oersi-etl/-/issues/64.

As long as there is no API break introduced (i.e. nothing that is already released would be broken) I am slack
@fsteeg may want to throw 2 cents?

@blackwinter
Copy link
Member

But how would you consume the updated version after the merge? Aren't you running from a checked out branch anyway?

I'm not saying it would be better for you to change the branch in your build, but would it be an option? Would you consider it preferable to merging this "unfinished" pull request?

@blackwinter
Copy link
Member

As long as there is no API break introduced (i.e. nothing that is already released would be broken)

How confident are we about that without any tests? ;)

@dr0i
Copy link
Member Author

dr0i commented Aug 29, 2022

How confident are we about that without any tests? ;)

as we didn't have a test before we cannot test against anything. Besides some flux scripts which does API calls and manually check if the old ones do work as before.
And yes, proper tests would be better of course.

@dr0i
Copy link
Member Author

dr0i commented Aug 29, 2022

I'm not saying it would be better for you to change the branch in your build, but would it be an option?

yes, it would. Ok, so I am going to use this PR at it is to implement agains it. (sorry for the noise, just getting a bit impatient ;) )

@blackwinter
Copy link
Member

yes, it would. Ok, so I am going to use this PR at it is to implement agains it.

Okay, thanks :)

(sorry for the noise, just getting a bit impatient ;) )

I know the feeling all too well ;)

@blackwinter
Copy link
Member

as we didn't have a test before we cannot test against anything.

Whatever new tests we devise, we can run against the previous implementation. But until then we're in the dark, yes.

@blackwinter
Copy link
Member

While spiking out an approach for unit tests, I noticed that URLConnection.setDoOutput(true) changes a GET request to POST. I.e., we can't initiate a GET request with a payload body.

Is this something we need to be able to support? It's technically undefined, but quite common with Elasticsearch for instance.

`HttpUrlConnection` throws `IOException` when trying to read `inputStream` instead of populating `errorStream`.
blackwinter added a commit that referenced this pull request Sep 1, 2022
@blackwinter
Copy link
Member

Added unit tests; documentation (Javadoc) could still use some work.

@blackwinter blackwinter changed the title Extend http opener Extend HttpOpener. Sep 1, 2022
@blackwinter blackwinter assigned dr0i and unassigned blackwinter Sep 1, 2022
@blackwinter
Copy link
Member

@dr0i: Would you review the pull request? Can't seem to request a review from the submitter.

@dr0i
Copy link
Member Author

dr0i commented Sep 5, 2022

can't initiate a GET request with a payload body.

As an example you referenced Elasticsearch, but then Elasticsearch also allows POST, so we can stick to POST. So IMO we don't need to support "Get with payload body".

@blackwinter
Copy link
Member

blackwinter commented Sep 5, 2022

Yes, Elasticsearch also supports POST. It's just that it might be unexpected if you initiate a GET request that then gets silently converted to something else (as a practical example: If your Elasticsearch sits behind a firewall that only allows GET, your search request fails for no apparent reason).

It's only an issue with server implementations that behave differently for GET with body vs. POST.

@dr0i
Copy link
Member Author

dr0i commented Sep 5, 2022

Re: "GET with body vs. POST" :
I understand that we can implement later, if need really arises, get a Response Body doing a GET, without breaking the API.

@blackwinter
Copy link
Member

Yes, I think we should proceed with the current implementation. I was just surprised by this behaviour and wanted to make sure we're on the same page.

@acka47
Copy link
Contributor

acka47 commented Sep 5, 2022

Re. GET with payload body, I like this post which made me aware of the HTTP QUERY Method (current draft). The post mentioned writes:

This is a new method, that’s not quite standard yet but any compliant HTTP client and server should already support it.

For rhe reconciliation API I just created an issue to track this. We should probably seriously consider supporting QUERY in the HTTPOpener as well.

@blackwinter
Copy link
Member

We should probably seriously consider supporting QUERY in the HTTPOpener as well.

We're currently limited to the request methods that HttpURLConnection.setRequestMethod() supports. If we need other methods or generally more flexibility, we'd have to replace it with a different implementation.

Only read `errorStream` _after_ reading `inputStream` failed. (Thanks to @dr0i for the hint!)

Drops use of response code range to determine failure handling. (864f0da)
@dr0i dr0i assigned blackwinter and unassigned dr0i Sep 8, 2022
@blackwinter blackwinter merged commit b142587 into master Sep 8, 2022
@blackwinter blackwinter deleted the extendHttpOpener branch September 8, 2022 07:58
@blackwinter blackwinter mentioned this pull request Sep 8, 2022
@dr0i dr0i mentioned this pull request Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Http POST
3 participants