https://kotlinlang.org logo
#ktor
Title
# ktor
j

Jason Han

04/21/2022, 8:08 PM
hi all, is it expected that ByteReadChannel removes newlines? If so, is there a way to preserve the newlines instead?
e

e5l

04/21/2022, 8:08 PM
Hi! Could you tell me how you are reading from channel?
j

Jason Han

04/21/2022, 8:10 PM
we're trying to do something like this
Copy code
OutgoingContent.WriteChannelContent() {
  override val contentType = RdfContentTypes.Turtle
  override suspend fun writeTo(channel: ByteWriteChannel) {
    call.request.receiveChannel().copyTo(channel)
}
where we want to forward the request body to another service
e

e5l

04/21/2022, 8:11 PM
It should keep new lines in this case. Could you try use logging or reading body as string?
j

Jason Han

04/21/2022, 8:11 PM
i have, and it does seem to remove newlines
encoding should be default UTF-8, so not sure what's going on
call.request.receiveChannel().readUTF8Line()
should preserve newlines as well right?
e

e5l

04/21/2022, 8:15 PM
It will read line by line
j

Jason Han

04/21/2022, 8:22 PM
ok so that is definitely concatenating lines
i'm sending an rdf turtle file, and i see all the prefixes on one line doing that
Copy code
INFO  Application - @prefix rdf: <<http://www.w3.org/1999/02/22-rdf-syntax-ns#>> .@prefix rdfs: <<http://www.w3.org/2000/01/rdf-schema#>> .@prefix owl: <<http://www.w3.org/2002/07/owl#>> .@prefix xsd: <<http://www.w3.org/2001/XMLSchema#>>
where our source file looks like this
Copy code
@prefix rdf: <<http://www.w3.org/1999/02/22-rdf-syntax-ns#>> .
@prefix rdfs: <<http://www.w3.org/2000/01/rdf-schema#>> .
@prefix owl: <<http://www.w3.org/2002/07/owl#>> .
@prefix xsd: <<http://www.w3.org/2001/XMLSchema#>> .
encoding is in utf-8-unix
e

e5l

04/30/2022, 6:29 PM
Could you log an issue? I will take a look
3 Views