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

expose addAuthentication and local context to subclasses #163

Merged
merged 3 commits into from
Jul 18, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -61,7 +62,7 @@ public class JenkinsHttpClient {

private URI uri;
private CloseableHttpClient client;
private BasicHttpContext localContext;
private HttpContext localContext;
private HttpResponseValidator httpResponseValidator;
// private HttpResponseContentExtractor contentExtractor;

Expand Down Expand Up @@ -161,7 +162,11 @@ public JenkinsHttpClient(URI uri, String username, String password) {
*/
public <T extends BaseModel> T get(String path, Class<T> cls) throws IOException {
HttpGet getMethod = new HttpGet(api(path));

System.out.println(getMethod.getURI());
System.out.println(getMethod.getRequestLine());
Copy link
Member

Choose a reason for hiding this comment

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

System.out is never good idea in production code...better use logging..? I have introduced a logging in cf65279#diff-f14ef3181c6e40c08aac9c02ba835778....

HttpResponse response = client.execute(getMethod, localContext);
System.out.println(response.getStatusLine());
getJenkinsVersionFromHeader(response);
try {
httpResponseValidator.validateResponse(response);
Expand Down Expand Up @@ -534,11 +539,11 @@ protected static HttpClientBuilder addAuthentication(HttpClientBuilder builder,
return builder;
}

protected BasicHttpContext getLocalContext() {
protected HttpContext getLocalContext() {
return localContext;
}

protected void setLocalContext(BasicHttpContext localContext) {
protected void setLocalContext(HttpContext localContext) {
this.localContext = localContext;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import java.io.IOException;

class PreemptiveAuth implements HttpRequestInterceptor {
public class PreemptiveAuth implements HttpRequestInterceptor {

@Override
public void process(HttpRequest request, HttpContext context) throws HttpException, IOException {
Expand Down