-
Notifications
You must be signed in to change notification settings - Fork 55
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
Conversation
45f186d
to
567e39c
Compare
|
||
void setParams(HttpParams httpParams); | ||
|
||
void setRedirectStrategy(LaxRedirectStrategy laxRedirectStrategy); |
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'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
.
508bab9
to
9f7a079
Compare
230b6f0
to
7c123ad
Compare
import com.google.common.base.Optional; | ||
import com.google.common.collect.Iterables; | ||
|
||
public class HttpExecutorFactory { |
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.
Should be an interface
Looks like a great start. |
6bde585
to
e50161b
Compare
.build()); | ||
return createHttpToolRespose(response); | ||
}}; | ||
getPoller().scheduleAtFixedRate(pollJob, new DelegatingPollHandler(handlers), minPeriod); |
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.
Wrong indentation here.
A few fixes in here ygy#3 |
return (Poller<HttpToolResponse>) super.getPoller(); | ||
} | ||
|
||
private HttpToolResponse createHttpToolRespose(HttpResponse response) throws IOException { |
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.
very minor - syntax error - "response"
instructions. */ | ||
if (responseCode == 422) { | ||
throw new IOException(" Unprocessable Entity: " + response.reasonPhrase()); | ||
} |
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.
Still don't see why we need special handling of 422? (to discuss).
d7397d8
to
26f0b5e
Compare
Multimap<String, String> headers(); | ||
|
||
@Nullable | ||
Credentials.BasicAuth credentials(); |
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.
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
toUsernamePassword(Credentials)
. - Change Credentials to interface (with getUser, getPassword method) and implement it in the above.
- Use Credentials in the API.
Almost there, only concerned about the content length being available on responses. |
3447ecf
to
4132491
Compare
ByteStreams.copy(response.getContent(), out); | ||
content = out.toByteArray(); | ||
} catch (IOException e) { | ||
throw Throwables.propagate(e); |
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 Brooklyn the recommended is Exceptions.propagate
, but this works as well in this case.
5cf8c3c
to
07d2207
Compare
07d2207
to
f9f3b99
Compare
Thanks @ygy, merging. |
No description provided.