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

Adding HttpExecutor to be used for interchangeable implementations #285

Merged
merged 9 commits into from
Sep 6, 2016

Conversation

ygy
Copy link
Contributor

@ygy ygy commented Aug 3, 2016

No description provided.


void setParams(HttpParams httpParams);

void setRedirectStrategy(LaxRedirectStrategy laxRedirectStrategy);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not convinced we want to tie this interface to the org.apache.http classes. I was assuming we'd make it more general. And that we would not extend HttpClient, which would presumably make it a lot harder to supply implementations which do not use org.apache.http.

@ygy ygy force-pushed the feature/http-executor branch 3 times, most recently from 508bab9 to 9f7a079 Compare August 16, 2016 15:46
@ygy ygy changed the title [WIP] Adding HttpExecutor to be used for interchangeable implementations Adding HttpExecutor to be used for interchangeable implementations Aug 22, 2016
@ygy
Copy link
Contributor Author

ygy commented Aug 22, 2016

@nakomis @neykov Can you review this PR?

import com.google.common.base.Optional;
import com.google.common.collect.Iterables;

public class HttpExecutorFactory {
Copy link
Member

Choose a reason for hiding this comment

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

Should be an interface

@neykov
Copy link
Member

neykov commented Aug 22, 2016

Looks like a great start.

.build());
return createHttpToolRespose(response);
}};
getPoller().scheduleAtFixedRate(pollJob, new DelegatingPollHandler(handlers), minPeriod);
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrong indentation here.

@bostko
Copy link
Contributor

bostko commented Aug 23, 2016

A few fixes in here ygy#3

return (Poller<HttpToolResponse>) super.getPoller();
}

private HttpToolResponse createHttpToolRespose(HttpResponse response) throws IOException {
Copy link
Contributor

@ivanayov ivanayov Aug 25, 2016

Choose a reason for hiding this comment

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

very minor - syntax error - "response"

instructions. */
if (responseCode == 422) {
throw new IOException(" Unprocessable Entity: " + response.reasonPhrase());
}
Copy link
Member

Choose a reason for hiding this comment

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

Still don't see why we need special handling of 422? (to discuss).

Multimap<String, String> headers();

@Nullable
Credentials.BasicAuth credentials();
Copy link
Member

Choose a reason for hiding this comment

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

Don't like how BasicAuth is hardcoded in the API. Username + password could be used for digest or a number of other schemes. The credentials are (mostly) orthogonal to the scheme.

  • Rename BasicAuth to UsernamePassword(Credentials).
  • Change Credentials to interface (with getUser, getPassword method) and implement it in the above.
  • Use Credentials in the API.

@neykov
Copy link
Member

neykov commented Sep 5, 2016

Almost there, only concerned about the content length being available on responses.
I'd like to see tests covering the extensions config key in jclouds and byon locations - can be done in another PR.

@ygy ygy force-pushed the feature/http-executor branch 2 times, most recently from 3447ecf to 4132491 Compare September 5, 2016 16:30
ByteStreams.copy(response.getContent(), out);
content = out.toByteArray();
} catch (IOException e) {
throw Throwables.propagate(e);
Copy link
Member

Choose a reason for hiding this comment

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

In Brooklyn the recommended is Exceptions.propagate, but this works as well in this case.

@ygy ygy closed this Sep 5, 2016
@ygy ygy reopened this Sep 5, 2016
@ygy ygy closed this Sep 5, 2016
@ygy ygy reopened this Sep 5, 2016
@ygy ygy closed this Sep 6, 2016
@ygy ygy reopened this Sep 6, 2016
@neykov
Copy link
Member

neykov commented Sep 6, 2016

Thanks @ygy, merging.

@asfgit asfgit merged commit f9f3b99 into apache:master Sep 6, 2016
asfgit pushed a commit that referenced this pull request Sep 6, 2016
Adding HttpExecutor to be used for interchangeable implementations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants