本文整理了Java中oauth.signpost.http.HttpRequest.unwrap()
方法的一些代码示例,展示了HttpRequest.unwrap()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.unwrap()
方法的具体详情如下:
包路径:oauth.signpost.http.HttpRequest
类名称:HttpRequest
方法名:unwrap
[英]Returns the wrapped request object, in case you must work directly on it.
[中]返回包装的请求对象,以防您必须直接处理它。
代码示例来源:origin: mttkay/signpost
@Override
protected void closeConnection(HttpRequest request, HttpResponse response) {
HttpURLConnection connection = (HttpURLConnection) request.unwrap();
if (connection != null) {
connection.disconnect();
}
}
}
代码示例来源:origin: mttkay/signpost
@Override
protected oauth.signpost.http.HttpResponse sendRequest(HttpRequest request) throws Exception {
HttpResponse response = httpClient.execute((HttpUriRequest) request.unwrap());
return new HttpResponseAdapter(response);
}
代码示例来源:origin: mttkay/signpost
protected HttpResponse sendRequest(HttpRequest request) throws IOException {
HttpURLConnection connection = (HttpURLConnection) request.unwrap();
connection.connect();
return new HttpURLConnectionResponseAdapter(connection);
}
代码示例来源:origin: mttkay/signpost
@Override
protected oauth.signpost.http.HttpResponse sendRequest(HttpRequest request) throws Exception {
HttpMethod method = (HttpMethod) request.unwrap();
httpClient.executeMethod(method);
return new Http3ResponseAdapter(method);
}
代码示例来源:origin: mttkay/signpost
@Override
protected oauth.signpost.http.HttpResponse sendRequest(HttpRequest request) throws Exception {
HttpResponse resp = httpClientMock.execute((HttpUriRequest) request.unwrap());
return new HttpResponseAdapter(resp);
}
代码示例来源:origin: oauth.signpost/signpost-core
@Override
protected void closeConnection(HttpRequest request, HttpResponse response) {
HttpURLConnection connection = (HttpURLConnection) request.unwrap();
if (connection != null) {
connection.disconnect();
}
}
}
代码示例来源:origin: oauth.signpost/signpost-commonshttp4
@Override
protected oauth.signpost.http.HttpResponse sendRequest(HttpRequest request) throws Exception {
HttpResponse response = httpClient.execute((HttpUriRequest) request.unwrap());
return new HttpResponseAdapter(response);
}
代码示例来源:origin: oauth.signpost/signpost-core
protected HttpResponse sendRequest(HttpRequest request) throws IOException {
HttpURLConnection connection = (HttpURLConnection) request.unwrap();
connection.connect();
return new HttpURLConnectionResponseAdapter(connection);
}
代码示例来源:origin: org.codehaus.groovy.modules.http-builder/http-builder
HttpURLConnection sign( HttpURLConnection request, final HttpEntity body ) throws IOException {
try { // OAuth Sign.
// Note that the request body must be repeatable even though it is an input stream.
if ( body == null ) return (HttpURLConnection)oauth.sign( request ).unwrap();
else return (HttpURLConnection)oauth.sign(
new HttpURLConnectionRequestAdapter(request) {
/* @Override */
public InputStream getMessagePayload() throws IOException {
return body.getContent();
}
}).unwrap();
}
catch ( final OAuthException ex ) {
// throw new IOException( "OAuth signing error", ex ); // 1.6 only!
throw new IOException( "OAuth signing error: " + ex.getMessage() ) {
private static final long serialVersionUID = -13848840190384656L;
/* @Override */ public Throwable getCause() { return ex; }
};
}
}
}
代码示例来源:origin: andstatus/andstatus
@Override
protected oauth.signpost.http.HttpResponse sendRequest(HttpRequest request) throws Exception {
HttpResponse response = httpClient.execute((HttpUriRequest) request.unwrap());
return new HttpResponseAdapter(response);
}
代码示例来源:origin: jgritman/httpbuilder
HttpURLConnection sign( HttpURLConnection request, final HttpEntity body ) throws IOException {
try { // OAuth Sign.
// Note that the request body must be repeatable even though it is an input stream.
if ( body == null ) return (HttpURLConnection)oauth.sign( request ).unwrap();
else return (HttpURLConnection)oauth.sign(
new HttpURLConnectionRequestAdapter(request) {
/* @Override */
public InputStream getMessagePayload() throws IOException {
return body.getContent();
}
}).unwrap();
}
catch ( final OAuthException ex ) {
// throw new IOException( "OAuth signing error", ex ); // 1.6 only!
throw new IOException( "OAuth signing error: " + ex.getMessage() ) {
private static final long serialVersionUID = -13848840190384656L;
/* @Override */ public Throwable getCause() { return ex; }
};
}
}
}
代码示例来源:origin: jenkinsci/jira-steps-plugin
@Override
public Response intercept(Interceptor.Chain chain) throws IOException {
if (jiraSite.getLoginType().equalsIgnoreCase(Site.LoginType.BASIC.name())) {
String credentials = jiraSite.getUserName() + ":" + jiraSite.getPassword().getPlainText();
String encodedHeader =
"Basic " + new String(Base64.getEncoder().encode(credentials.getBytes()));
Request requestWithAuthorization =
chain.request().newBuilder().addHeader("Authorization", encodedHeader).build();
return chain.proceed(requestWithAuthorization);
} else if (jiraSite.getLoginType().equalsIgnoreCase(Site.LoginType.OAUTH.name())) {
Request request = chain.request();
OAuthConsumer consumer =
new OAuthConsumer(jiraSite.getConsumerKey(), jiraSite.getPrivateKey());
consumer.setTokenWithSecret(jiraSite.getToken().getPlainText(),
jiraSite.getSecret().getPlainText());
consumer.setMessageSigner(new RsaSha1MessageSigner());
try {
return chain.proceed((Request) consumer.sign(request).unwrap());
} catch (OAuthException e) {
throw new IOException("Error signing request with OAuth.", e);
}
} else {
throw new IOException("Invalid Login Type, this isn't expected.");
}
}
内容来源于网络,如有侵权,请联系作者删除!