下面列出了怎么用retrofit2.http.HEAD的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public Set<String> getSupportedAnnotationTypes() {
Set<String> annotations = new LinkedHashSet<String>();
annotations.add(GET.class.getCanonicalName());
annotations.add(PUT.class.getCanonicalName());
annotations.add(POST.class.getCanonicalName());
annotations.add(DELETE.class.getCanonicalName());
annotations.add(HEAD.class.getCanonicalName());
return annotations;
}
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.resources.Resources checkExistence" })
@HEAD("subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}")
Observable<Response<Void>> checkExistence(@Path("resourceGroupName") String resourceGroupName, @Path("resourceProviderNamespace") String resourceProviderNamespace, @Path(value = "parentResourcePath", encoded = true) String parentResourcePath, @Path(value = "resourceType", encoded = true) String resourceType, @Path("resourceName") String resourceName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.resources.Resources checkExistenceById" })
@HEAD("{resourceId}")
Observable<Response<Void>> checkExistenceById(@Path(value = "resourceId", encoded = true) String resourceId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.resources.ResourceGroups checkExistence" })
@HEAD("subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}")
Observable<Response<Void>> checkExistence(@Path("resourceGroupName") String resourceGroupName, @Path("subscriptionId") String subscriptionId, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
@Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.management.cosmosdb.DatabaseAccounts checkNameExists" })
@HEAD("providers/Microsoft.DocumentDB/databaseAccountNames/{accountName}")
Observable<Response<Void>> checkNameExists(@Path("accountName") String accountName, @Query("api-version") String apiVersion, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent);
@HEAD
Call<Void> getImageSize(@Url String imageUrl);
@HEAD("{index}/{type}/{id}")
public Call<Void> exists(@Path("index") String index, @Path("type") String type, @Path("id") String id);
@HEAD("{index}")
public Call<Void> indices_exists(@Path("index") String index);
@HEAD("_alias/{name}")
public Call<Void> indices_exists_alias(@Path("name") String name);
@HEAD("{index}/_alias/{name}")
public Call<Void> indices_exists_alias(@Path("index") String index, @Path("name") String name);
@HEAD("{index}/_alias")
public Call<Void> indices_exists_alias2(@Path("index") String index);
@HEAD("_template/{name}")
public Call<Void> indices_exists_template(@Path("name") String name);
@HEAD("{index}/_mapping/{type}")
public Call<Void> indices_exists_type(@Path("index") String index, @Path("type") String type);
@HEAD("")
public Call<Void> ping();
@HEAD("/foo")
CompletableFuture<Void> headFoo();
@HEAD("/head")
Call<Void> head();
private void parseMethodAnnotation(Annotation annotation) {
if (annotation instanceof DELETE) {
parseHttpMethodAndPath("DELETE", ((DELETE) annotation).value(), false);
} else if (annotation instanceof GET) {
parseHttpMethodAndPath("GET", ((GET) annotation).value(), false);
} else if (annotation instanceof POST) {
parseHttpMethodAndPath("POST", ((POST) annotation).value(), true);
} else if (annotation instanceof PUT) {
parseHttpMethodAndPath("PUT", ((PUT) annotation).value(), true);
} else if (annotation instanceof HEAD) {
parseHttpMethodAndPath("HEAD", ((HEAD) annotation).value(), false);
} else if (annotation instanceof HTTP) {
HTTP http = (HTTP) annotation;
parseHttpMethodAndPath(http.method(), http.path(), http.hasBody());
} else if (annotation instanceof Multipart) {
if (isFormEncoded) {
throw methodError(method, "Only one encoding annotation is allowed.");
}
isMultipart = true;
} else if (annotation instanceof FormUrlEncoded) {
if (isMultipart) {
throw methodError(method, "Only one encoding annotation is allowed.");
}
isFormEncoded = true;
} else if (annotation instanceof Streaming) {
Log.v(TAG, "streaming interface");
} else if (annotation instanceof retrofit2.http.Headers) {
String[] headersToParse = ((retrofit2.http.Headers) annotation).value();
if (headersToParse.length == 0) {
throw methodError(method, "@Headers annotation is empty.");
}
headers = parseHeaders(headersToParse);
} else if(annotation instanceof FormUrlEncoded) {
//formUrlEncoded = true;
Log.v(TAG, "FormUrlEncoded request");
} else if(annotation instanceof NextcloudAPI.FollowRedirects) {
followRedirects = true;
} else {
throw new UnsupportedOperationException(String.valueOf(annotation));
}
}