本文整理汇总了Java中com.qiniu.util.StringMap.forEach方法的典型用法代码示例。如果您正苦于以下问题:Java StringMap.forEach方法的具体用法?Java StringMap.forEach怎么用?Java StringMap.forEach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.qiniu.util.StringMap
的用法示例。
在下文中一共展示了StringMap.forEach方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: multipartPost
import com.qiniu.util.StringMap; //导入方法依赖的package包/类
private Response multipartPost(String url,
StringMap fields,
String name,
String fileName,
RequestBody file,
StringMap headers) throws QiniuException {
final MultipartBuilder mb = new MultipartBuilder();
mb.addFormDataPart(name, fileName, file);
fields.forEach(new StringMap.Consumer() {
@Override
public void accept(String key, Object value) {
mb.addFormDataPart(key, value.toString());
}
});
mb.type(MediaType.parse("multipart/form-data"));
RequestBody body = mb.build();
Request.Builder requestBuilder = new Request.Builder().url(url).post(body);
return send(requestBuilder, headers);
}
示例2: filterParam
import com.qiniu.util.StringMap; //导入方法依赖的package包/类
/**
* 过滤用户自定义参数,只有参数名以<code>x:</code>开头的参数才会被使用
*
* @param params 待过滤的用户自定义参数
* @return 过滤后的用户自定义参数
*/
private static StringMap filterParam(StringMap params) {
final StringMap ret = new StringMap();
if (params == null) {
return ret;
}
params.forEach(new StringMap.Consumer() {
@Override
public void accept(String key, Object value) {
if (value == null) {
return;
}
String val = value.toString();
if (key.startsWith("x:") && !val.equals("")) {
ret.put(key, val);
}
}
});
return ret;
}
示例3: post
import com.qiniu.util.StringMap; //导入方法依赖的package包/类
public Response post(String url, StringMap params, StringMap headers) throws QiniuException {
final FormEncodingBuilder f = new FormEncodingBuilder();
params.forEach(new StringMap.Consumer() {
@Override
public void accept(String key, Object value) {
f.add(key, value.toString());
}
});
return post(url, f.build(), headers);
}
示例4: send
import com.qiniu.util.StringMap; //导入方法依赖的package包/类
public Response send(final Request.Builder requestBuilder, StringMap headers) throws QiniuException {
if (headers != null) {
headers.forEach(new StringMap.Consumer() {
@Override
public void accept(String key, Object value) {
requestBuilder.header(key, value.toString());
}
});
}
requestBuilder.header("User-Agent", userAgent());
long start = System.currentTimeMillis();
com.squareup.okhttp.Response res = null;
Response r;
double duration = (System.currentTimeMillis() - start) / 1000.0;
IpTag tag = new IpTag();
try {
res = httpClient.newCall(requestBuilder.tag(tag).build()).execute();
} catch (IOException e) {
e.printStackTrace();
throw new QiniuException(e);
}
r = Response.create(res, tag.ip, duration);
if (r.statusCode >= 300) {
throw new QiniuException(r);
}
return r;
}