android - Retrofit 2 检查调用 URL

标签 android http retrofit retrofit2

Retrofit 2 中是否有可能将 Call URL 与 String 进行比较?

例如我们可以采用这个baseUrl:

https://www.google.com

而这个调用:

public interface ExampleService {
    @GET("dummy/{examplePartialUrl}/")
    Call<JsonObject> exampleList(@Path("examplePartialUrl") String examplePartialUrl;
}

有了这个请求:

Call<JsonObject> mCall = dummyService.exampleList("partialDummy")

有没有办法在获得调用响应之前获取 https://www.google.com/dummy/partialDummydummy/partialDummy

最佳答案

假设您将 OkHttp 与 Retrofit 一起使用,您可以执行以下操作:

dummyService.exampleList("partialDummy").request().url().toString()

根据 OkHttp 文档应该打印:

https://www.google.com/dummy/partialDummy

关于android - Retrofit 2 检查调用 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36532273/

相关文章:

http - Golang clean items out of channel 不会被读取

ios - 在 iOS Swift 中使用 Alamofire 发送带有 MultipartFormData 的 POST 参数

ios - AFNetworking 识别失败原因 : User cancel request or network failure

java - Retrift API 中的 JSON 格式错误?

android - 将 OpenGL glBegin() 移植到 OpenGL ES

android - jsoup - 查找元素并将其与前一个元素一起删除

android - 如何使涟漪效果看起来像圆形而不是椭圆形?

android - 如何在android中实现语音命令识别?

android - Retrofit 不支持 CLEARTEXT 通信

javax.net.ssl.SSLHandshakeException : Handshake failed on Android 5. 0.0 禁用 SSLv2 和 SSlv3(仅限 TLS)(及更高版本)