Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixup a few javadoc & compile warnings #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/main/scala/fm/http/HttpContentChunkedInput.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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())
}
2 changes: 1 addition & 1 deletion src/main/scala/fm/http/PostData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
27 changes: 9 additions & 18 deletions src/main/scala/fm/http/server/DigestAuth.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
}
}
5 changes: 4 additions & 1 deletion src/main/scala/fm/http/server/RequestLocal.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
14 changes: 7 additions & 7 deletions src/main/scala/fm/http/server/RouteMatchers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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: ( ) | ?
*
Expand All @@ -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))
Expand All @@ -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))
}
Expand Down