@@ -24,6 +24,7 @@ import io.ktor.client.request.post
2424import io.ktor.client.request.setBody
2525import io.ktor.client.statement.bodyAsText
2626import io.ktor.http.ContentType
27+ import io.ktor.http.URLBuilder
2728import io.ktor.http.appendPathSegments
2829import io.ktor.http.contentType
2930import io.ktor.http.takeFrom
@@ -90,7 +91,7 @@ class ModelClientV2(
9091 val response = httpClient.post {
9192 url {
9293 takeFrom(baseUrl)
93- appendPathSegments (" repositories" , repository.id, " init" )
94+ appendPathSegmentsEncodingSlash (" repositories" , repository.id, " init" )
9495 }
9596 }
9697 val delta = response.body<VersionDelta >()
@@ -110,7 +111,7 @@ class ModelClientV2(
110111 return httpClient.get {
111112 url {
112113 takeFrom(baseUrl)
113- appendPathSegments (" repositories" , repository.id, " branches" )
114+ appendPathSegmentsEncodingSlash (" repositories" , repository.id, " branches" )
114115 }
115116 }.bodyAsText().lines().map { repository.getBranchReference(it) }
116117 }
@@ -138,7 +139,7 @@ class ModelClientV2(
138139 val response = httpClient.post {
139140 url {
140141 takeFrom(baseUrl)
141- appendPathSegments (" repositories" , branch.repositoryId.id, " branches" , branch.branchName)
142+ appendPathSegmentsEncodingSlash (" repositories" , branch.repositoryId.id, " branches" , branch.branchName)
142143 }
143144 contentType(ContentType .Application .Json )
144145 val body = VersionDelta (version.getContentHash(), null , objectsMap = objects)
@@ -154,7 +155,7 @@ class ModelClientV2(
154155 val response = httpClient.get {
155156 url {
156157 takeFrom(baseUrl)
157- appendPathSegments (" repositories" , branch.repositoryId.id, " branches" , branch.branchName)
158+ appendPathSegmentsEncodingSlash (" repositories" , branch.repositoryId.id, " branches" , branch.branchName)
158159 if (lastKnownVersion != null ) {
159160 parameters[" lastKnown" ] = lastKnownVersion.hash
160161 }
@@ -170,7 +171,7 @@ class ModelClientV2(
170171 val response = httpClient.get {
171172 url {
172173 takeFrom(baseUrl)
173- appendPathSegments (" repositories" , branch.repositoryId.id, " branches" , branch.branchName, " poll" )
174+ appendPathSegmentsEncodingSlash (" repositories" , branch.repositoryId.id, " branches" , branch.branchName, " poll" )
174175 if (lastKnownVersion != null ) {
175176 parameters[" lastKnown" ] = lastKnownVersion.hash
176177 }
@@ -280,5 +281,8 @@ expect class ModelClientV2PlatformSpecificBuilder() : ModelClientV2Builder
280281fun VersionDelta.checkObjectHashes () {
281282 HashUtil .checkObjectHashes(objectsMap)
282283}
284+ private fun URLBuilder.appendPathSegmentsEncodingSlash (vararg components : String ): URLBuilder {
285+ return appendPathSegments(components.toList(), true )
286+ }
283287
284288fun VersionDelta.getAllObjects (): Map <String , String > = objectsMap + objects.associateBy { HashUtil .sha256(it) }
0 commit comments