• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java HttpResponseMessage类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.oauth.http.HttpResponseMessage的典型用法代码示例。如果您正苦于以下问题:Java HttpResponseMessage类的具体用法?Java HttpResponseMessage怎么用?Java HttpResponseMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



HttpResponseMessage类属于net.oauth.http包,在下文中一共展示了HttpResponseMessage类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testRedirect

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
public void testRedirect() throws Exception {
    final OAuthMessage request = new OAuthMessage("GET",
            "http://google.com/search", OAuth.newList("q", "Java"));
    final Integer expectedStatus = Integer.valueOf(301);
    final String expectedLocation = "http://www.google.com/search?q=Java";
    for (OAuthClient client : clients) {
        try {
            OAuthMessage response = client.invoke(request, ParameterStyle.BODY);
            fail(client.getHttpClient() + " response: " + response);
        } catch (OAuthProblemException e) {
            Map<String, Object> parameters = e.getParameters();
            assertEquals("status", expectedStatus, parameters.get(HttpMessage.STATUS_CODE));
            assertEquals("Location", expectedLocation, parameters.get(HttpResponseMessage.LOCATION));
        }
    }
}
 
开发者ID:groovenauts,项目名称:jmeter_oauth_plugin,代码行数:17,代码来源:OAuthClientTest.java


示例2: OAuthResponseMessage

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
OAuthResponseMessage(HttpResponseMessage http) throws IOException
{
    super(http.method, http.url.toExternalForm(), null);
    this.http = http;
    getHeaders().addAll(http.headers);
    for (Map.Entry<String, String> header : http.headers) {
        if ("WWW-Authenticate".equalsIgnoreCase(header.getKey())) {
            for (OAuth.Parameter parameter : decodeAuthorization(header.getValue())) {
                if (!"realm".equalsIgnoreCase(parameter.getKey())) {
                    addParameter(parameter);
                }
            }
        }
    }
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:16,代码来源:OAuthResponseMessage.java


示例3: access

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
/**
 * Send a request and return the response. Don't try to decide whether the
 * response indicates success; merely return it.
 */
public OAuthResponseMessage access(OAuthMessage request,  net.oauth.ParameterStyle style) throws IOException {
    HttpMessage httpRequest = HttpMessage.newRequest(request, style);
    HttpResponseMessage httpResponse = http.execute(httpRequest, httpParameters);
    httpResponse = HttpMessageDecoder.decode(httpResponse);
    return new OAuthResponseMessage(httpResponse);
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:11,代码来源:OAuthClient.java


示例4: getMessage

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
@Override
public String getMessage() {
    String msg = super.getMessage();
    if (msg != null)
        return msg;
    msg = getProblem();
    if (msg != null)
        return msg;
    Object response = getParameters().get(HttpMessage.RESPONSE);
    if (response != null) {
        msg = response.toString();
        int eol = msg.indexOf("\n");
        if (eol < 0) {
            eol = msg.indexOf("\r");
        }
        if (eol >= 0) {
            msg = msg.substring(0, eol);
        }
        msg = msg.trim();
        if (msg.length() > 0) {
            return msg;
        }
    }
    response = getHttpStatusCode();
    if (response != null) {
        return HttpResponseMessage.STATUS_CODE + " " + response;
    }
    return null;
}
 
开发者ID:lshain-android-source,项目名称:external-oauth,代码行数:30,代码来源:OAuthProblemException.java


示例5: getHttpStatusCode

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
public int getHttpStatusCode() {
    Object code = getParameters().get(HttpResponseMessage.STATUS_CODE);
    if (code == null) {
        return 200;
    } else if (code instanceof Number) { // the usual case
        return ((Number) code).intValue();
    } else {
        return Integer.parseInt(code.toString());
    }
}
 
开发者ID:lshain-android-source,项目名称:external-oauth,代码行数:11,代码来源:OAuthProblemException.java


示例6: execute

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
public HttpResponseMessage execute(HttpMessage request) throws IOException {
    final String method = request.method;
    final String url = request.url.toExternalForm();
    final InputStream body = request.getBody();
    final boolean isDelete = DELETE.equalsIgnoreCase(method);
    final boolean isPost = POST.equalsIgnoreCase(method);
    final boolean isPut = PUT.equalsIgnoreCase(method);
    byte[] excerpt = null;
    HttpRequestBase httpRequest;
    if (isPost || isPut) {
        HttpEntityEnclosingRequestBase entityEnclosingMethod =
            isPost ? new HttpPost(url) : new HttpPut(url);
        if (body != null) {
            ExcerptInputStream e = new ExcerptInputStream(body);
            excerpt = e.getExcerpt();
            String length = request.removeHeaders(HttpMessage.CONTENT_LENGTH);
            entityEnclosingMethod.setEntity(new InputStreamEntity(e,
                    (length == null) ? -1 : Long.parseLong(length)));
        }
        httpRequest = entityEnclosingMethod;
    } else if (isDelete) {
        httpRequest = new HttpDelete(url);
    } else {
        httpRequest = new HttpGet(url);
    }
    for (Map.Entry<String, String> header : request.headers) {
        httpRequest.addHeader(header.getKey(), header.getValue());
    }
    HttpClient client = clientPool.getHttpClient(new URL(httpRequest.getURI().toString()));
    client.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
    HttpResponse httpResponse = client.execute(httpRequest);
    return new HttpMethodResponse(httpRequest, httpResponse, excerpt, request.getContentCharset());
}
 
开发者ID:lshain-android-source,项目名称:external-oauth,代码行数:34,代码来源:HttpClient4.java


示例7: execute

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
public HttpResponseMessage execute(HttpMessage request, Map<String, Object> parameters) throws IOException {
	request.headers.add(entry);
	return super.execute(request, parameters);
}
 
开发者ID:YouCanBookMe,项目名称:jXero,代码行数:5,代码来源:HeaderSettableHttpClient.java


示例8: OAuthResponseMessage

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
OAuthResponseMessage(HttpResponseMessage http) throws IOException {
	super(http.method, http.url.toExternalForm(), null);
	this.http = http;
	getHeaders().addAll(http.headers);
	for (Map.Entry<String, String> header : http.headers) {
		if ("WWW-Authenticate".equalsIgnoreCase(header.getKey())) {
			for (OAuth.Parameter parameter : decodeAuthorization(header
					.getValue())) {
				if (!"realm".equalsIgnoreCase(parameter.getKey())) {
					addParameter(parameter);
				}
			}
		}
	}
}
 
开发者ID:Simbacode,项目名称:mobipayments,代码行数:16,代码来源:OAuthResponseMessage.java


示例9: access

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
/**
 * Send a request and return the response. Don't try to decide whether the
 * response indicates success; merely return it.
 */
public OAuthResponseMessage access(OAuthMessage request,
		ParameterStyle style) throws IOException {
	HttpMessage httpRequest = HttpMessage.newRequest(request, style);
	HttpResponseMessage httpResponse = http.execute(httpRequest,
			httpParameters);
	httpResponse = HttpMessageDecoder.decode(httpResponse);
	return new OAuthResponseMessage(httpResponse);
}
 
开发者ID:Simbacode,项目名称:mobipayments,代码行数:13,代码来源:OAuthClient.java


示例10: doGet

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    OAuthConsumer consumer = null;
    try {
        consumer = CookieConsumer.getConsumer("twitter", getServletContext());
        OAuthAccessor accessor = CookieConsumer.getAccessor(request, response, consumer);
        OAuthResponseMessage result = CookieConsumer.CLIENT.access(accessor.newRequestMessage(OAuthMessage.GET,
                "http://twitter.com/statuses/friends_timeline.atom", null), ParameterStyle.AUTHORIZATION_HEADER);
        int status = result.getHttpResponse().getStatusCode();
        if (status != HttpResponseMessage.STATUS_OK) {
            OAuthProblemException problem = result.toOAuthProblemException();
            if (problem.getProblem() != null) {
                throw problem;
            }
            Map<String, Object> dump = problem.getParameters();
            response.setContentType("text/plain");
            PrintWriter out = response.getWriter();
            out.println(dump.get(HttpMessage.REQUEST));
            out.println("----------------------");
            out.println(dump.get(HttpMessage.RESPONSE));
        } else {
            // Simply pass the data through to the browser:
            CookieConsumer.copyResponse(result, response);
        }
    } catch (Exception e) {
        CookieConsumer.handleException(e, request, response, consumer);
    }
}
 
开发者ID:groovenauts,项目名称:jmeter_oauth_plugin,代码行数:29,代码来源:TwitterConsumer.java


示例11: access

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
/**
 * Send a request and return the response. Don't try to decide whether the
 * response indicates success; merely return it.
 */
public OAuthResponseMessage access(OAuthMessage request, ParameterStyle style) throws IOException {
    HttpMessage httpRequest = HttpMessage.newRequest(request, style);
    HttpResponseMessage httpResponse = http.execute(httpRequest, httpParameters);
    httpResponse = HttpMessageDecoder.decode(httpResponse);
    return new OAuthResponseMessage(httpResponse);
}
 
开发者ID:aoprisan,项目名称:net.oauth,代码行数:11,代码来源:OAuthClient.java


示例12: execute

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
@Override
public HttpResponseMessage execute(HttpMessage request, Map<String, Object> stringObjectMap)
    throws IOException {
  String body = readInputStream(request.getBody());
  OutputStreamWriter out;
  HttpURLConnection conn;
  // Open the connection.
  conn = (HttpURLConnection) request.url.openConnection();
  conn.setReadTimeout(fetchTimeout);
  conn.setRequestMethod(request.method);
  // Add the headers
  if (request.headers != null) {
    for (java.util.Map.Entry<String, String> header : request.headers) {
      conn.setRequestProperty(header.getKey(), header.getValue());
    }
  }

  boolean doOutput =
      body != null && (HTTP_POST_METHOD.equalsIgnoreCase(request.method)
      || HTTP_PUT_METHOD.equalsIgnoreCase(request.method));

  if (doOutput) {
    conn.setDoOutput(true);
  }

  conn.connect();

  if (doOutput) {
    // Send the request body.
    out = new OutputStreamWriter(conn.getOutputStream(), UTF_8);
    try {
      out.write(body);
      out.flush();
    } finally {
      out.close();
    }
  }

  // Return the response stream.
  return new HttpResponse(
      request.method, request.url, conn.getResponseCode(), conn.getInputStream());
}
 
开发者ID:jorkey,项目名称:Wiab.pro,代码行数:43,代码来源:WaveService.java


示例13: getHttpResponse

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
public HttpResponseMessage getHttpResponse() {
    return http;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:4,代码来源:OAuthResponseMessage.java


示例14: execute

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
@Override
public HttpResponseMessage execute(HttpMessage request, Map<String, Object> stringObjectMap)
    throws IOException {
  String body = readInputStream(request.getBody());
  OutputStreamWriter out = null;
  HttpURLConnection conn = null;
  // Open the connection.
  conn = (HttpURLConnection) request.url.openConnection();
  conn.setReadTimeout(fetchTimeout);
  conn.setRequestMethod(request.method);
  // Add the headers
  if (request.headers != null) {
    for (java.util.Map.Entry<String, String> header : request.headers) {
      conn.setRequestProperty(header.getKey(), header.getValue());
    }
  }

  boolean doOutput =
      body != null && (HTTP_POST_METHOD.equalsIgnoreCase(request.method)
          || HTTP_PUT_METHOD.equalsIgnoreCase(request.method));

  if (doOutput) {
    conn.setDoOutput(true);
  }

  conn.connect();

  if (doOutput) {
    // Send the request body.
    out = new OutputStreamWriter(conn.getOutputStream(), UTF_8);
    try {
      out.write(body);
      out.flush();
    } finally {
      out.close();
    }
  }

  // Return the response stream.
  return new HttpResponse(
      request.method, request.url, conn.getResponseCode(), conn.getInputStream());
}
 
开发者ID:apache,项目名称:incubator-wave,代码行数:43,代码来源:WaveService.java


示例15: getHttpResponse

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
public HttpResponseMessage getHttpResponse() {
	return http;
}
 
开发者ID:Simbacode,项目名称:mobipayments,代码行数:4,代码来源:OAuthResponseMessage.java


示例16: execute

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
public HttpResponseMessage execute(HttpMessage request,
		Map<String, Object> parameters) throws IOException {
	final String method = request.method;
	final String url = request.url.toExternalForm();
	final InputStream body = request.getBody();
	final boolean isDelete = DELETE.equalsIgnoreCase(method);
	final boolean isPost = POST.equalsIgnoreCase(method);
	final boolean isPut = PUT.equalsIgnoreCase(method);
	byte[] excerpt = null;
	HttpRequestBase httpRequest;
	if (isPost || isPut) {
		HttpEntityEnclosingRequestBase entityEnclosingMethod = isPost ? new HttpPost(
				url) : new HttpPut(url);
		if (body != null) {
			ExcerptInputStream e = new ExcerptInputStream(body);
			excerpt = e.getExcerpt();
			String length = request
					.removeHeaders(HttpMessage.CONTENT_LENGTH);
			entityEnclosingMethod.setEntity(new InputStreamEntity(e,
					(length == null) ? -1 : Long.parseLong(length)));
		}
		httpRequest = entityEnclosingMethod;
	} else if (isDelete) {
		httpRequest = new HttpDelete(url);
	} else {
		httpRequest = new HttpGet(url);
	}
	for (Map.Entry<String, String> header : request.headers) {
		httpRequest.addHeader(header.getKey(), header.getValue());
	}
	HttpParams params = httpRequest.getParams();
	for (Map.Entry<String, Object> p : parameters.entrySet()) {
		String name = p.getKey();
		String value = p.getValue().toString();
		if (FOLLOW_REDIRECTS.equals(name)) {
			params.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS,
					Boolean.parseBoolean(value));
		} else if (READ_TIMEOUT.equals(name)) {
			params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT,
					Integer.parseInt(value));
		} else if (CONNECT_TIMEOUT.equals(name)) {
			params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
					Integer.parseInt(value));
		}
	}

	params.setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE,
			false);

	HttpClient client = clientPool.getHttpClient(new URL(httpRequest
			.getURI().toString()));
	HttpResponse httpResponse = client.execute(httpRequest);
	return new HttpMethodResponse(httpRequest, httpResponse, excerpt,
			request.getContentCharset());
}
 
开发者ID:Simbacode,项目名称:mobipayments,代码行数:56,代码来源:HttpClient4.java


示例17: execute

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
public HttpResponseMessage execute(HttpMessage request, Map<String, Object> parameters) throws IOException {
    final String method = request.method;
    final String url = request.url.toExternalForm();
    final InputStream body = request.getBody();
    final boolean isDelete = DELETE.equalsIgnoreCase(method);
    final boolean isPost = POST.equalsIgnoreCase(method);
    final boolean isPut = PUT.equalsIgnoreCase(method);
    byte[] excerpt = null;
    HttpRequestBase httpRequest;
    if (isPost || isPut) {
        HttpEntityEnclosingRequestBase entityEnclosingMethod = isPost ? new HttpPost(url) : new HttpPut(url);
        if (body != null) {
            ExcerptInputStream e = new ExcerptInputStream(body);
            excerpt = e.getExcerpt();
            String length = request.removeHeaders(HttpMessage.CONTENT_LENGTH);
            entityEnclosingMethod
                    .setEntity(new InputStreamEntity(e, (length == null) ? -1 : Long.parseLong(length)));
        }
        httpRequest = entityEnclosingMethod;
    } else if (isDelete) {
        httpRequest = new HttpDelete(url);
    } else {
        httpRequest = new HttpGet(url);
    }
    for (Map.Entry<String, String> header : request.headers) {
        httpRequest.addHeader(header.getKey(), header.getValue());
    }
    HttpParams params = httpRequest.getParams();
    for (Map.Entry<String, Object> p : parameters.entrySet()) {
        String name = p.getKey();
        String value = p.getValue().toString();
        if (FOLLOW_REDIRECTS.equals(name)) {
            params.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.parseBoolean(value));
        } else if (READ_TIMEOUT.equals(name)) {
            params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, Integer.parseInt(value));
        } else if (CONNECT_TIMEOUT.equals(name)) {
            params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, Integer.parseInt(value));
        }
    }
    HttpClient client = clientPool.getHttpClient(new URL(httpRequest.getURI().toString()));
    HttpResponse httpResponse = client.execute(httpRequest);
    return new HttpMethodResponse(httpRequest, httpResponse, excerpt, request.getContentCharset());
}
 
开发者ID:groovenauts,项目名称:jmeter_oauth_plugin,代码行数:44,代码来源:HttpClient4.java


示例18: execute

import net.oauth.http.HttpResponseMessage; //导入依赖的package包/类
public HttpResponseMessage execute(HttpMessage request, Map<String, Object> parameters) throws IOException {
    final String method = request.method;
    final String url = request.url.toExternalForm();
    final InputStream body = request.getBody();
    final boolean isDelete = DELETE.equalsIgnoreCase(method);
    final boolean isPost = POST.equalsIgnoreCase(method);
    final boolean isPut = PUT.equalsIgnoreCase(method);
    byte[] excerpt = null;
    HttpRequestBase httpRequest;
    if (isPost || isPut) {
        HttpEntityEnclosingRequestBase entityEnclosingMethod = isPost ? new HttpPost(url) : new HttpPut(url);
        if (body != null) {
            ExcerptInputStream e = new ExcerptInputStream(body);
            excerpt = e.getExcerpt();
            String length = request.removeHeaders(HttpMessage.CONTENT_LENGTH);
            entityEnclosingMethod
                    .setEntity(new InputStreamEntity(e, (length == null) ? -1 : Long.parseLong(length)));
        }
        httpRequest = entityEnclosingMethod;
    } else if (isDelete) {
        httpRequest = new HttpDelete(url);
    } else {
        httpRequest = new HttpGet(url);
    }
    for (Map.Entry<String, String> header : request.headers) {
        httpRequest.addHeader(header.getKey(), header.getValue());
    }
    HttpParams params = httpRequest.getParams();
    for (Map.Entry<String, Object> p : parameters.entrySet()) {
        String name = p.getKey();
        String value = p.getValue().toString();
        if (FOLLOW_REDIRECTS.equals(name)) {
            params.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, Boolean.parseBoolean(value));
        } else if (READ_TIMEOUT.equals(name)) {
            params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, Integer.parseInt(value));
        } else if (CONNECT_TIMEOUT.equals(name)) {
            params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, Integer.parseInt(value));
        }
    }
    
    params.setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE,false); 

    HttpClient client = clientPool.getHttpClient(new URL(httpRequest.getURI().toString()));
    HttpResponse httpResponse = client.execute(httpRequest);
    return new HttpMethodResponse(httpRequest, httpResponse, excerpt, request.getContentCharset());
}
 
开发者ID:aoprisan,项目名称:net.oauth,代码行数:47,代码来源:HttpClient4.java



注:本文中的net.oauth.http.HttpResponseMessage类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IContainerTooltipHandler类代码示例发布时间:2022-05-23
下一篇:
Java XSElementDecl类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap