forked from thunderbird/thunderbird-android
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom result type for
HttpFetcher
- Loading branch information
Showing
10 changed files
with
81 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
...scovery/autoconfig/src/main/kotlin/app/k9mail/autodiscovery/autoconfig/HttpFetchResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package app.k9mail.autodiscovery.autoconfig | ||
|
||
import java.io.InputStream | ||
|
||
/** | ||
* Result type for [HttpFetcher]. | ||
*/ | ||
internal sealed interface HttpFetchResult { | ||
/** | ||
* The HTTP request returned a success response. | ||
* | ||
* @param inputStream Contains the response body. | ||
*/ | ||
data class SuccessResponse( | ||
val inputStream: InputStream, | ||
) : HttpFetchResult | ||
|
||
/** | ||
* The server returned an error response. | ||
* | ||
* @param code The HTTP status code. | ||
*/ | ||
data class ErrorResponse(val code: Int) : HttpFetchResult | ||
} |
3 changes: 1 addition & 2 deletions
3
...todiscovery/autoconfig/src/main/kotlin/app/k9mail/autodiscovery/autoconfig/HttpFetcher.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
package app.k9mail.autodiscovery.autoconfig | ||
|
||
import java.io.InputStream | ||
import okhttp3.HttpUrl | ||
|
||
internal interface HttpFetcher { | ||
suspend fun fetch(url: HttpUrl): InputStream? | ||
suspend fun fetch(url: HttpUrl): HttpFetchResult | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters