当前位置: 首页>>代码示例>>Java>>正文


Java Param类代码示例

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


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

示例1: signatureBaseString

import org.asynchttpclient.Param; //导入依赖的package包/类
StringBuilder signatureBaseString(String method, Uri uri, long oauthTimestamp, String nonce,
                                 List<Param> formParams, List<Param> queryParams) {
    
    // beware: must generate first as we're using pooled StringBuilder
    String baseUrl = baseUrl(uri);
    String encodedParams = encodedParams(oauthTimestamp, nonce, formParams, queryParams);

    StringBuilder sb = StringUtils.stringBuilder();
    sb.append(method); // POST / GET etc (nothing to URL encode)
    sb.append('&');
    Utf8UrlEncoder.encodeAndAppendQueryElement(sb, baseUrl);


    // and all that needs to be URL encoded (... again!)
    sb.append('&');
    Utf8UrlEncoder.encodeAndAppendQueryElement(sb, encodedParams);
    return sb;
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:19,代码来源:OAuthSignatureCalculator.java

示例2: send

import org.asynchttpclient.Param; //导入依赖的package包/类
public void send(String to, String text) {
    ArrayList<Param> params = new ArrayList<>();
    params.add(new Param("api_key", key));
    params.add(new Param("api_secret", secret));
    params.add(new Param("from", "Blynk"));
    params.add(new Param("to", to));
    params.add(new Param("text", text));

    httpclient.preparePost("https://rest.nexmo.com/sms/json")
            .setQueryParams(params)
            .execute(new AsyncCompletionHandler<Response>() {
                @Override
                public Response onCompleted(org.asynchttpclient.Response response) throws Exception {
                    if (response.getStatusCode() == 200) {
                        SmsResponse smsResponse = smsResponseReader.readValue(response.getResponseBody());
                        if (!smsResponse.messages[0].status.equals("0")) {
                            log.error(smsResponse.messages[0].error);
                        }
                    }
                    return response;
                }
            });


}
 
开发者ID:blynkkk,项目名称:blynk-server,代码行数:26,代码来源:SMSWrapper.java

示例3: paramsToString

import org.asynchttpclient.Param; //导入依赖的package包/类
/**
 * Returns string without double quotations marks, spaces, semi-colons from com.ning.http.client.FluentStringsMap.toString()
 *
 * @param params
 * @param limit
 * @return
 */
private String paramsToString(List<Param> params, int limit) {
    StringBuilder result = new StringBuilder(limit * 2);

    for (Param param : params) {
        if (result.length() > 0) {
            result.append(',');
        }
        result.append(param.getName());
        result.append('=');
        result.append(param.getValue());
        if (result.length() >= limit) {
            break;
        }
    }
    return result.toString();
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:24,代码来源:ExecuteInterceptor.java

示例4: visitCustomHeaders

import org.asynchttpclient.Param; //导入依赖的package包/类
protected void visitCustomHeaders(PartVisitor visitor) {
    if (isNonEmpty(part.getCustomHeaders())) {
        for (Param param : part.getCustomHeaders()) {
            visitor.withBytes(CRLF_BYTES);
            visitor.withBytes(param.getName().getBytes(US_ASCII));
            visitor.withBytes(param.getValue().getBytes(US_ASCII));
        }
    }
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:10,代码来源:MultipartPart.java

示例5: urlEncodeFormParams0

import org.asynchttpclient.Param; //导入依赖的package包/类
private static StringBuilder urlEncodeFormParams0(List<Param> params) {
    StringBuilder sb = StringUtils.stringBuilder();
    for (Param param : params) {
        encodeAndAppendFormParam(sb, param.getName(), param.getValue());
    }
    sb.setLength(sb.length() - 1);
    return sb;
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:9,代码来源:HttpUtils.java

示例6: testGetCalculateSignature

import org.asynchttpclient.Param; //导入依赖的package包/类
@Test(groups = "standalone")
public void testGetCalculateSignature() {
    ConsumerKey consumer = new ConsumerKey(CONSUMER_KEY, CONSUMER_SECRET);
    RequestToken user = new RequestToken(TOKEN_KEY, TOKEN_SECRET);
    OAuthSignatureCalculator calc = new OAuthSignatureCalculator(consumer, user);
    List<Param> queryParams = new ArrayList<>();
    queryParams.add(new Param("file", "vacation.jpg"));
    queryParams.add(new Param("size", "original"));
    String url = "http://photos.example.net/photos";
    String sig = calc.calculateSignature("GET", Uri.create(url), TIMESTAMP, NONCE, null, queryParams);

    assertEquals(sig, "tR3+Ty81lMeYAr/Fid0kMTYa/WM=");
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:14,代码来源:OAuthSignatureCalculatorTest.java

示例7: testPostCalculateSignature

import org.asynchttpclient.Param; //导入依赖的package包/类
@Test(groups = "standalone")
public void testPostCalculateSignature() {
    ConsumerKey consumer = new ConsumerKey(CONSUMER_KEY, CONSUMER_SECRET);
    RequestToken user = new RequestToken(TOKEN_KEY, TOKEN_SECRET);
    OAuthSignatureCalculator calc = new StaticOAuthSignatureCalculator(consumer, user, TIMESTAMP, NONCE);

    List<Param> formParams = new ArrayList<Param>();
    formParams.add(new Param("file", "vacation.jpg"));
    formParams.add(new Param("size", "original"));
    String url = "http://photos.example.net/photos";
    final Request req = post(url)//
            .setFormParams(formParams)//
            .setSignatureCalculator(calc)//
            .build();

    // From the signature tester, POST should look like:
    // normalized parameters:
    // file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original
    // signature base string:
    // POST&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal
    // signature: wPkvxykrw+BTdCcGqKr+3I+PsiM=
    // header: OAuth
    // realm="",oauth_version="1.0",oauth_consumer_key="dpf43f3p2l4k3l03",oauth_token="nnch734d00sl2jdk",oauth_timestamp="1191242096",oauth_nonce="kllo9940pd9333jh",oauth_signature_method="HMAC-SHA1",oauth_signature="wPkvxykrw%2BBTdCcGqKr%2B3I%2BPsiM%3D"

    String authHeader = req.getHeaders().get("Authorization");
    Matcher m = Pattern.compile("oauth_signature=\"(.+?)\"").matcher(authHeader);
    assertEquals(m.find(), true);
    String encodedSig = m.group(1);
    String sig = null;
    try {
        sig = URLDecoder.decode(encodedSig, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        fail("bad encoding", e);
    }

    assertEquals(sig, "wPkvxykrw+BTdCcGqKr+3I+PsiM=");
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:38,代码来源:OAuthSignatureCalculatorTest.java

示例8: testGetWithRequestBuilderAndQuery

import org.asynchttpclient.Param; //导入依赖的package包/类
@Test(groups = "standalone")
public void testGetWithRequestBuilderAndQuery() {
    ConsumerKey consumer = new ConsumerKey(CONSUMER_KEY, CONSUMER_SECRET);
    RequestToken user = new RequestToken(TOKEN_KEY, TOKEN_SECRET);
    OAuthSignatureCalculator calc = new StaticOAuthSignatureCalculator(consumer, user, TIMESTAMP, NONCE);

    String url = "http://photos.example.net/photos?file=vacation.jpg&size=original";

    final Request req = get(url)//
            .setSignatureCalculator(calc)//
            .build();

    final List<Param> params = req.getQueryParams();
    assertEquals(params.size(), 2);

    // From the signature tester, the URL should look like:
    //normalized parameters: file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original
    //signature base string: GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal
    //signature: tR3+Ty81lMeYAr/Fid0kMTYa/WM=
    //Authorization header: OAuth realm="",oauth_version="1.0",oauth_consumer_key="dpf43f3p2l4k3l03",oauth_token="nnch734d00sl2jdk",oauth_timestamp="1191242096",oauth_nonce="kllo9940pd9333jh",oauth_signature_method="HMAC-SHA1",oauth_signature="tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D"

    String authHeader = req.getHeaders().get("Authorization");
    Matcher m = Pattern.compile("oauth_signature=\"(.+?)\"").matcher(authHeader);
    assertEquals(m.find(), true);
    String encodedSig = m.group(1);
    String sig = null;
    try {
        sig = URLDecoder.decode(encodedSig, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        fail("bad encoding", e);
    }

    assertEquals(sig, "tR3+Ty81lMeYAr/Fid0kMTYa/WM=");
    assertEquals(req.getUrl(), "http://photos.example.net/photos?file=vacation.jpg&size=original");
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:36,代码来源:OAuthSignatureCalculatorTest.java

示例9: recordParam

import org.asynchttpclient.Param; //导入依赖的package包/类
protected void recordParam(final Request httpRequest, final SpanEventRecorder recorder) {
    if (paramSampler.isSampling()) {
        List<Param> requestParams = httpRequest.getFormParams();
        if (requestParams != null && !requestParams.isEmpty()) {
            String params = paramsToString(requestParams, config.getParamDumpSize());
            recorder.recordAttribute(AnnotationKey.HTTP_PARAM, StringUtils.abbreviate(params, config.getParamDumpSize()));
        }
    }
}
 
开发者ID:naver,项目名称:pinpoint,代码行数:10,代码来源:ExecuteInterceptor.java

示例10: getCustomHeaders

import org.asynchttpclient.Param; //导入依赖的package包/类
@Override
public List<Param> getCustomHeaders() {
    return customHeaders;
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:5,代码来源:PartBase.java

示例11: addCustomHeader

import org.asynchttpclient.Param; //导入依赖的package包/类
public void addCustomHeader(String name, String value) {
    if (customHeaders == null) {
        customHeaders = new ArrayList<Param>(2);
    }
    customHeaders.add(new Param(name, value));
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:7,代码来源:PartBase.java

示例12: setCustomHeaders

import org.asynchttpclient.Param; //导入依赖的package包/类
public void setCustomHeaders(List<Param> customHeaders) {
    this.customHeaders = customHeaders;
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:4,代码来源:PartBase.java

示例13: urlEncodeFormParams

import org.asynchttpclient.Param; //导入依赖的package包/类
public static ByteBuffer urlEncodeFormParams(List<Param> params, Charset charset) {
    return StringUtils.charSequence2ByteBuffer(urlEncodeFormParams0(params), charset);
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:4,代码来源:HttpUtils.java

示例14: testGetWithRequestBuilder

import org.asynchttpclient.Param; //导入依赖的package包/类
@Test(groups = "standalone")
public void testGetWithRequestBuilder() {
    ConsumerKey consumer = new ConsumerKey(CONSUMER_KEY, CONSUMER_SECRET);
    RequestToken user = new RequestToken(TOKEN_KEY, TOKEN_SECRET);
    OAuthSignatureCalculator calc = new StaticOAuthSignatureCalculator(consumer, user, TIMESTAMP, NONCE);

    List<Param> queryParams = new ArrayList<Param>();
    queryParams.add(new Param("file", "vacation.jpg"));
    queryParams.add(new Param("size", "original"));
    String url = "http://photos.example.net/photos";

    final Request req = get(url)//
            .setQueryParams(queryParams)//
            .setSignatureCalculator(calc)//
            .build();

    final List<Param> params = req.getQueryParams();
    assertEquals(params.size(), 2);

    // From the signature tester, the URL should look like:
    // normalized parameters:
    // file=vacation.jpg&oauth_consumer_key=dpf43f3p2l4k3l03&oauth_nonce=kllo9940pd9333jh&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1191242096&oauth_token=nnch734d00sl2jdk&oauth_version=1.0&size=original
    // signature base string:
    // GET&http%3A%2F%2Fphotos.example.net%2Fphotos&file%3Dvacation.jpg%26oauth_consumer_key%3Ddpf43f3p2l4k3l03%26oauth_nonce%3Dkllo9940pd9333jh%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1191242096%26oauth_token%3Dnnch734d00sl2jdk%26oauth_version%3D1.0%26size%3Doriginal
    // signature: tR3+Ty81lMeYAr/Fid0kMTYa/WM=
    // Authorization header: OAuth
    // realm="",oauth_version="1.0",oauth_consumer_key="dpf43f3p2l4k3l03",oauth_token="nnch734d00sl2jdk",oauth_timestamp="1191242096",oauth_nonce="kllo9940pd9333jh",oauth_signature_method="HMAC-SHA1",oauth_signature="tR3%2BTy81lMeYAr%2FFid0kMTYa%2FWM%3D"

    String authHeader = req.getHeaders().get("Authorization");
    Matcher m = Pattern.compile("oauth_signature=\"(.+?)\"").matcher(authHeader);
    assertEquals(m.find(), true);
    String encodedSig = m.group(1);
    String sig = null;
    try {
        sig = URLDecoder.decode(encodedSig, "UTF-8");
    } catch (UnsupportedEncodingException e) {
        fail("bad encoding", e);
    }

    assertEquals(sig, "tR3+Ty81lMeYAr/Fid0kMTYa/WM=");
    assertEquals(req.getUrl(), "http://photos.example.net/photos?file=vacation.jpg&size=original");
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:43,代码来源:OAuthSignatureCalculatorTest.java

示例15: calculateSignature

import org.asynchttpclient.Param; //导入依赖的package包/类
/**
 * Method for calculating OAuth signature using HMAC/SHA-1 method.
 * 
 * @param method the request methode
 * @param uri the request Uri
 * @param oauthTimestamp the timestamp
 * @param nonce the nonce
 * @param formParams the formParams
 * @param queryParams the query params
 * @return the signature
 */
public String calculateSignature(String method, Uri uri, long oauthTimestamp, String nonce,
                                 List<Param> formParams, List<Param> queryParams) {

    StringBuilder sb = signatureBaseString(method, uri, oauthTimestamp, nonce, formParams, queryParams);

    ByteBuffer rawBase = StringUtils.charSequence2ByteBuffer(sb, UTF_8);
    byte[] rawSignature = mac.digest(rawBase);
    // and finally, base64 encoded... phew!
    return Base64.encode(rawSignature);
}
 
开发者ID:amaralDaniel,项目名称:megaphone,代码行数:22,代码来源:OAuthSignatureCalculator.java


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