diff --git a/src/main/scala/fm/http/HttpContentChunkedInput.scala b/src/main/scala/fm/http/HttpContentChunkedInput.scala index 85f17e8..0640c23 100644 --- a/src/main/scala/fm/http/HttpContentChunkedInput.scala +++ b/src/main/scala/fm/http/HttpContentChunkedInput.scala @@ -37,9 +37,9 @@ final case class HttpContentChunkedInput(input: ChunkedInput[ByteBuf]) extends C * thus the stream has reached at its end, any subsequent isEndOfInput() call must * return false. * - * @returns the fetched chunk. null if there is no data left in the stream. Please - * note that null does not necessarily mean that the stream has reached at - * its end. In a slow stream, the next chunk might be unavailable just momentarily. + * @return The fetched chunk. null if there is no data left in the stream. Please + * note that null does not necessarily mean that the stream has reached at + * its end. In a slow stream, the next chunk might be unavailable just momentarily. */ def readChunk(allocator: ByteBufAllocator): HttpContent = { if (isEndOfInput) return LastHttpContent.EMPTY_LAST_CONTENT @@ -52,9 +52,9 @@ final case class HttpContentChunkedInput(input: ChunkedInput[ByteBuf]) extends C * thus the stream has reached at its end, any subsequent isEndOfInput() call must * return false. * - * @returns the fetched chunk. null if there is no data left in the stream. Please - * note that null does not necessarily mean that the stream has reached at - * its end. In a slow stream, the next chunk might be unavailable just momentarily. + * @return The fetched chunk. null if there is no data left in the stream. Please + * note that null does not necessarily mean that the stream has reached at + * its end. In a slow stream, the next chunk might be unavailable just momentarily. */ def readChunk(ctx: ChannelHandlerContext): HttpContent = readChunk(ctx.alloc()) } \ No newline at end of file diff --git a/src/main/scala/fm/http/PostData.scala b/src/main/scala/fm/http/PostData.scala index f9457c6..d04dbf5 100644 --- a/src/main/scala/fm/http/PostData.scala +++ b/src/main/scala/fm/http/PostData.scala @@ -53,7 +53,7 @@ sealed trait PostData { final def value: String = self.getString() - /** Force this data to disk (if it's not already there) */ + ///** Force this data to disk (if it's not already there) */ //def toDiskPostData: DiskPostData } diff --git a/src/main/scala/fm/http/server/DigestAuth.scala b/src/main/scala/fm/http/server/DigestAuth.scala index 45205fe..3621e83 100644 --- a/src/main/scala/fm/http/server/DigestAuth.scala +++ b/src/main/scala/fm/http/server/DigestAuth.scala @@ -80,31 +80,22 @@ object DigestAuth { * * Mostly used the Wikipedia pages as references: * http://en.wikipedia.org/wiki/Digest_access_authentication - * + * * NOTE: Use at your own risk. We make no claim that any of this Crypto code is correct. + * + * @param realm The realm to use + * @param users Map of Usernames -> (Plaintext passwords or hashes based on the digestHash method in the DigestAuth object) + * @param noncePrefix A value to prefix to the nonce. Can be anything. + * @param base64EncryptionKey The Base64 encoded 256-bit encryption key to use for encrypting the opaque data. You + * can use fm.common.Crypto.makeRandomKeyBase64() to generate a key. + * @param expirationSeconds How long is the nonce good for? After this amount of seconds the client's browser + * will automatically re-authenticate using the updated nonce from the server. */ final case class DigestAuth( - /** - * The realm to use - */ realm: String, - /** - * Map of Usernames -> (Plaintext passwords or hashes based on the digestHash method in the DigestAuth object) - */ users: Map[String, String], - /** - * A value to prefix to the nonce. Can be anything. - */ noncePrefix: String, - /** - * The Base64 encoded 256-bit encryption key to use for encrypting the opaque data. You - * can use fm.common.Crypto.makeRandomKeyBase64() to generate a key. - */ base64EncryptionKey: String, - /** - * How long is the nonce good for? After this amount of seconds the client's browser - * will automatically re-authenticate using the updated nonce from the server. - */ expirationSeconds: Int = 300 // 5 minutes ) extends Auth with Logging { diff --git a/src/main/scala/fm/http/server/NettyHttpServerPipelineHandler.scala b/src/main/scala/fm/http/server/NettyHttpServerPipelineHandler.scala index 06534e7..4e53046 100644 --- a/src/main/scala/fm/http/server/NettyHttpServerPipelineHandler.scala +++ b/src/main/scala/fm/http/server/NettyHttpServerPipelineHandler.scala @@ -225,7 +225,8 @@ final class NettyHttpServerPipelineHandler(channelGroup: ChannelGroup, execution /** * Set common headers for both Full & Async responses */ - private def prepareResponse[T <: HttpResponse](request: Request, response: T, wantKeepAlive: Boolean)(implicit ctx: ChannelHandlerContext): T = { + private def prepareResponse[T <: HttpResponse](request: Request, response: T, wantKeepAlive: Boolean)(implicit ctx: ChannelHandlerContext /* TODO: Scala 2.13: @unused */): T = { + assert(ctx.isNotNull) // hack to suppress unused warning HttpUtil.setKeepAlive(response, wantKeepAlive) // Set the "Date" HTTP Header if it isn't already set @@ -468,4 +469,4 @@ final class NettyHttpServerPipelineHandler(channelGroup: ChannelGroup, execution private def trace(name: String, ex: Throwable = null)(implicit ctx: ChannelHandlerContext): Unit = { if (logger.isTraceEnabled) logger.trace(s"$id - $name - ${ctx.channel}", ex) } -} \ No newline at end of file +} diff --git a/src/main/scala/fm/http/server/RequestLocal.scala b/src/main/scala/fm/http/server/RequestLocal.scala index 44be426..13fe481 100644 --- a/src/main/scala/fm/http/server/RequestLocal.scala +++ b/src/main/scala/fm/http/server/RequestLocal.scala @@ -109,5 +109,8 @@ class RequestLocal[T] { /** * Override this is you want to have a default value that is set on first access if set() hasn't been called */ - protected def initialValue(implicit request: Request): Option[T] = None + protected def initialValue(implicit request: Request /* TODO: 2.13 @unused */): Option[T] = { + assert(request.isNotNull) // hack to suppress unused warning + None + } } diff --git a/src/main/scala/fm/http/server/RouteMatchers.scala b/src/main/scala/fm/http/server/RouteMatchers.scala index d73ae25..657723b 100644 --- a/src/main/scala/fm/http/server/RouteMatchers.scala +++ b/src/main/scala/fm/http/server/RouteMatchers.scala @@ -31,16 +31,16 @@ object RouteMatchers { implicit class RichPathMatchers(val sc: StringContext) extends AnyVal { /** * This support simple patterns of the form: - * /path/$part ==> Will match /path/foo, /path/bar, etc... - * /path/$part* ==> Will match /path/to/somewhere, /path/foo/bar, /path/foo, etc... + * /path/\$part ==> Will match /path/foo, /path/bar, etc... + * /path/\$part* ==> Will match /path/to/somewhere, /path/foo/bar, /path/foo, etc... * * By default a variable will match everything up to the next / character. * If the * is used then the / character is also included. * * Other simple regex operators are also now supported: * - * /path/$part/? ==> Allow an optional trailing slash - * /path/$part.(gif|jpg) ==> Allows either gif or jpg extension + * /path/\$part/? ==> Allow an optional trailing slash + * /path/\$part.(gif|jpg) ==> Allows either gif or jpg extension * * These are operators are supported: ( ) | ? * @@ -49,9 +49,9 @@ object RouteMatchers { * However those operators must be self-contained within each part of the string. * This means you can't have something like: * - * /path(/$part)? ==> DOES NOT WORK - The grouping operator spans multiple parts of the string + * /path(/\$part)? ==> DOES NOT WORK - The grouping operator spans multiple parts of the string * - * TODO: make this work with query params. e.g.: /path/$var?foo=$foo + * TODO: make this work with query params. e.g.: /path/\$var?foo=\$foo */ def simple = RichPathMatchingRegex(makeSimpleRegex(sc)) def p = RichPathMatchingRegex(makeSimpleRegex(sc)) @@ -61,7 +61,7 @@ object RouteMatchers { * * e.g.: * - * /path/(?<$rest>.+) ==> Will match /path/to/somewhere with the "to/somewhere" being bound the the "rest" variable + * /path/(?<\$rest>.+) ==> Will match /path/to/somewhere with the "to/somewhere" being bound the the "rest" variable */ def regex = RichPathMatchingRegex(makeFullRegex(sc)) }