本文整理汇总了Java中retrofit2.http.HeaderMap类的典型用法代码示例。如果您正苦于以下问题:Java HeaderMap类的具体用法?Java HeaderMap怎么用?Java HeaderMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HeaderMap类属于retrofit2.http包,在下文中一共展示了HeaderMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: headerMapMustBeAMap
import retrofit2.http.HeaderMap; //导入依赖的package包/类
@Test public void headerMapMustBeAMap() {
class Example {
@GET("/")
Call<ResponseBody> method(@HeaderMap List<String> headers) {
return null;
}
}
try {
buildRequest(Example.class);
fail();
} catch (IllegalArgumentException e) {
assertThat(e).hasMessage(
"@HeaderMap parameter type must be Map. (parameter #1)\n for method Example.method");
}
}
示例2: headerMapRejectsNull
import retrofit2.http.HeaderMap; //导入依赖的package包/类
@Test public void headerMapRejectsNull() {
class Example {
@GET("/")
Call<ResponseBody> method(@HeaderMap Map<String, String> headers) {
return null;
}
}
try {
buildRequest(Example.class, (Map<String, String>) null);
fail();
} catch (IllegalArgumentException e) {
assertThat(e).hasMessage("Header map was null.");
}
}
示例3: executeUpload
import retrofit2.http.HeaderMap; //导入依赖的package包/类
/**
* 上传文件
* @param url
* @param headerMap
* @param paramPartList
* @return
*/
@Multipart
@POST
Call<ResponseBody> executeUpload(
@Url String url,
@HeaderMap Map<String, String> headerMap,
@Part() List<MultipartBody.Part> paramPartList
);
示例4: executeDownload
import retrofit2.http.HeaderMap; //导入依赖的package包/类
/**
* 下载文件
* @param url
* @param headerMap
* @param txtParamMap
* @return
*/
@Streaming
@GET
Call<ResponseBody> executeDownload(
@Url String url,
@HeaderMap Map<String, String> headerMap,
@QueryMap Map<String, String> txtParamMap
);
示例5: getAsync
import retrofit2.http.HeaderMap; //导入依赖的package包/类
public static <T> Call getAsync(String apiUrl, @HeaderMap Map<String, Object> headers, Map<String, Object> paramMap, final HttpResponse<T> httpResponse) {
if (paramMap == null) {
paramMap = new HashMap<>();
}
if (headers == null) {
headers = new HashMap<>();
}
HttpService httpService = getInstance().mRetrofit.create(HttpService.class);
Call<ResponseBody> call = httpService.get(apiUrl, headers, paramMap);
parseNetData(call, httpResponse);
return call;
}
示例6: postAsync
import retrofit2.http.HeaderMap; //导入依赖的package包/类
public static <T> Call postAsync(String apiUrl, @HeaderMap Map<String, Object> headers, Map<String, Object> paramMap, HttpResponse<T> httpResponse) {
if (paramMap == null) {
paramMap = new HashMap<>();
}
if (headers == null) {
headers = new HashMap<>();
}
HttpService httpService = getInstance().mRetrofit.create(HttpService.class);
Call<ResponseBody> call = httpService.post(apiUrl, headers, paramMap);
parseNetData(call, httpResponse);
return call;
}
示例7: submitFeedbackForm
import retrofit2.http.HeaderMap; //导入依赖的package包/类
@POST("applications/{id}/submit")
Call<ResponseBody> submitFeedbackForm(
@HeaderMap final Map<String, String> httpHeaders,
@Path("id") final int applicationId,
@Query("key") final String key,
@Query("email") final String email,
@Query("message") final String message,
@Query("name") final String userName,
@Query("properties") final String propertiesJson,
@Query("attachments[]") final String[] attachments);
示例8: uploadScreenshot
import retrofit2.http.HeaderMap; //导入依赖的package包/类
@Multipart
@POST("applications/{id}/upload")
Call<String[]> uploadScreenshot(
@HeaderMap final Map<String, String> httpHeaders,
@Path("id") final int applicationId,
@Query("key") final String key,
@Part("files[]\"; filename=\"screenshot.png\" ") final RequestBody filename);
示例9: uploadLogs
import retrofit2.http.HeaderMap; //导入依赖的package包/类
@Multipart
@POST("applications/{id}/upload")
Call<String[]> uploadLogs(
@HeaderMap final Map<String, String> httpHeaders,
@Path("id") final int applicationId,
@Query("key") final String key,
@Part("files[]\"; filename=\"logs.txt\" ") final RequestBody filename);
示例10: download
import retrofit2.http.HeaderMap; //导入依赖的package包/类
@Streaming
@GET
Call<ResponseBody> download(@Url String url, @HeaderMap Map<String,String> headerMap);
示例11: uploadS3
import retrofit2.http.HeaderMap; //导入依赖的package包/类
@PUT
Call<ResponseBody> uploadS3(
@HeaderMap Map<String, String> headers,
@Url String url,
@Body RequestBody body);
示例12: login
import retrofit2.http.HeaderMap; //导入依赖的package包/类
@FormUrlEncoded
@POST("/login")
Observable<ResponseBody> login(@HeaderMap Map<String, String> csrfToken, @Field("username") String userName, @Field("password") String password);
示例13: register
import retrofit2.http.HeaderMap; //导入依赖的package包/类
@FormUrlEncoded
@POST("/register")
Observable<ResponseBody> register(@HeaderMap Map<String, String> csrfToken, @Field("email") String email,
@Field("username") String userName, @Field("password") String password, @Field("password-confirm") String repeatPassword);
示例14: logout
import retrofit2.http.HeaderMap; //导入依赖的package包/类
@POST("/logout")
Observable<ResponseBody> logout(@HeaderMap Map<String, String> csrfToken);
示例15: get
import retrofit2.http.HeaderMap; //导入依赖的package包/类
@GET()
Call<String> get(@HeaderMap Map<String, String> headers, @Url String url, @QueryMap Map<String, String> params);