@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"); } }
@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."); } }
/** * 上传文件 * @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 );
/** * 下载文件 * @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 );
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; }
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; }
@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);
@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);
@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);
@Streaming @GET Call<ResponseBody> download(@Url String url, @HeaderMap Map<String,String> headerMap);
@PUT Call<ResponseBody> uploadS3( @HeaderMap Map<String, String> headers, @Url String url, @Body RequestBody body);
@FormUrlEncoded @POST("/login") Observable<ResponseBody> login(@HeaderMap Map<String, String> csrfToken, @Field("username") String userName, @Field("password") String password);
@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);
@POST("/logout") Observable<ResponseBody> logout(@HeaderMap Map<String, String> csrfToken);
@GET() Call<String> get(@HeaderMap Map<String, String> headers, @Url String url, @QueryMap Map<String, String> params);
@FormUrlEncoded @POST() Call<String> post(@HeaderMap Map<String, String> headers, @Url String url, @FieldMap Map<String, String> params);
@GET() Observable<String> Obget(@HeaderMap Map<String, String> headers, @Url String url, @QueryMap Map<String, String> params);
@FormUrlEncoded @POST() Observable<String> Obpost(@HeaderMap Map<String, String> headers, @Url String url, @FieldMap Map<String, String> params);
@Streaming @GET() Observable<ResponseBody> Obdownload(@HeaderMap Map<String, String> headers, @Url String url, @QueryMap Map<String, String> params);
@Streaming @GET() Call<ResponseBody> download(@HeaderMap Map<String, String> headers, @Url String url, @QueryMap Map<String, String> params);
@GET Call<ResponseBody> get(@Url String url, @HeaderMap Map<String, String> headers, @QueryMap Map<String, Object> param);
@FormUrlEncoded @POST Call<ResponseBody> post(@Url String url, @HeaderMap Map<String, String> headers, @FieldMap Map<String, Object> param);
@GET Observable<String> get(@Url String url, @QueryMap Map<String, Object> params, @HeaderMap Map<String, Object> header);
@FormUrlEncoded @POST Observable<String> post(@Url String url, @FieldMap Map<String, Object> params, @HeaderMap Map<String, Object> header);
@POST Observable<String> postRaw(@Url String url, @Body RequestBody body, @HeaderMap Map<String, Object> header);
@FormUrlEncoded @PUT Observable<String> put(@Url String url, @FieldMap Map<String, Object> params, @HeaderMap Map<String, Object> header);
@PUT Observable<String> putRaw(@Url String url, @Body RequestBody body, @HeaderMap Map<String, Object> header);
@DELETE Observable<String> delete(@Url String url, @QueryMap Map<String, Object> params, @HeaderMap Map<String, Object> header);
@Streaming @GET Observable<ResponseBody> download(@Url String url, @QueryMap Map<String, Object> params, @HeaderMap Map<String, Object> header);
@Multipart @POST Observable<String> upload(@Url String url, @Part MultipartBody.Part file, @HeaderMap Map<String, Object> header);
@Multipart @POST Observable<String> upload(@Url String url, @PartMap Map<String, MultipartBody.Part> files, @HeaderMap Map<String, Object> header);
@Multipart @POST Observable<String> upload(@Url String url, @PartMap Map<String, RequestBody> params, @Part MultipartBody.Part file, @HeaderMap Map<String, Object> header);
@Multipart @POST Observable<String> upload(@Url String url, @PartMap Map<String, RequestBody> params, @PartMap Map<String, MultipartBody.Part> files, @HeaderMap Map<String, Object> header);
@Headers({"DNT: 1"}) @GET("/cgi-bin/Hotbits?fmt=bin") Call<ResponseBody> getRandom(@HeaderMap Map<String, String> headers, @Query("nbytes") int bitLength, @Query("apikey") String apiKey);
@Headers({"DNT: 1"}) @GET("/API/jsonI.php?length=1&type=hex16") Call<AnuQuantumResponse> getRandom(@HeaderMap Map<String, String> headers, @Query("size") int byteLength);
@Headers({"DNT: 1"}) @POST("/json-rpc/1/invoke") Call<String> getRandom(@HeaderMap Map<String, String> headers, @Body RandomOrgBlobRequest request);
@FormUrlEncoded @POST("send") Call<SMSVerifyResponse> getVerifyCode(@HeaderMap Map<String, String> headers, @Field(ApiConstant.MOBILE) String mobile, @Field(ApiConstant.TEMPLATE_ID) String templateid);
@FormUrlEncoded @POST("verifycode.action") Call<ResponseBody> checkVerifyCode(@HeaderMap Map<String, String> headers, @Field(ApiConstant.MOBILE) String mobile, @Field(ApiConstant.CODE) String code);