spray is no longer maintained and has been superseded by Akka HTTP.
Please check out the migration guide for help with the upgrade.
Commercial support is available from Lightbend.
Please see http://spray.io/ for all documentation
A suite of scala libraries for building and consuming RESTful web services on top of Akka: lightweight, asynchronous, non-blocking, actor-based, testable
Home Page: http://spray.io
License: Other
spray is no longer maintained and has been superseded by Akka HTTP.
Please check out the migration guide for help with the upgrade.
Commercial support is available from Lightbend.
Please see http://spray.io/ for all documentation
Currently a _.complete("hello")
fails with an ambiguous implicits error when a JsonProtocol and SprayJsonSupport are in scope. However, since a JSON string cannot legally be the root object of a JSON document the sprayJsonMarshaller should not actually be available in this case.
The second test is failing with:
[error] x return the text 'dir' for GET requests to the path /a/
[error] 'Right(file)' is not equal to 'Right(dir)'
class ServiceBuilderSlashSpec extends Specification with SprayTest with ServiceBuilder { val simpleService = { path("a") { _.complete("file") } ~ path("a/") {_.complete("dir") } } "The simpleService" should { "return the text 'file' for GET requests to the path /a" in { testService(HttpRequest(GET, "/a")) { simpleService }.response.content.as[String] mustEqual Right("file") } "return the text 'dir' for GET requests to the path /a/" in { testService(HttpRequest(GET, "/a/")) { simpleService }.response.content.as[String] mustEqual Right("dir") } } }
Is this intended behavior?
django provides a config option and a middleware (i think) to append a slash and retry if no url pattern is matched.
in lift there is no way to distinguish between / and /index, because / apparently does not end with a slash. thats why i am looking for alternatives.
Hey,
I'm running the latest Spray release and am seeing a strange Cookie parsing error when I'm using Google Chrome.
[cc.spray.http.HttpException: Illegal HTTP header 'Cookie':
Invalid input '"', expected CookieValue, "; " or EOI (line 1, pos 68):
remember=rkapsi:7:ef873b03e76902f2d73ecc68a8c69140; crucibleprefs1="D%3D1302104992324%3Bssyn%3Djava%3Bslp%3Dt%3Basv%3Dfe"
^
at cc.spray.http.HttpHeader$.apply(HttpHeader.scala:35)
at cc.spray.ToFromRawConverter$$anonfun$buildHeaders$1.apply(ToFromRawConverter.scala:56)
at cc.spray.ToFromRawConverter$$anonfun$buildHeaders$1.apply(ToFromRawConverter.scala:55)
at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:93)
at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:93)
at scala.collection.Iterator$class.foreach(Iterator.scala:652)
at scala.collection.mutable.HashTable$$anon$1.foreach(HashTable.scala:157)
at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:190)
at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:43)
at scala.collection.mutable.HashMap.foreach(HashMap.scala:93)
at cc.spray.ToFromRawConverter$class.buildHeaders(ToFromRawConverter.scala:55)
at cc.spray.RootService.buildHeaders(RootService.scala:30)
at cc.spray.ToFromRawConverter$class.toSprayRequest(ToFromRawConverter.scala:40)
at cc.spray.RootService.toSprayRequest(RootService.scala:30)
at cc.spray.RootService.cc$spray$RootService$$handleOneService(RootService.scala:78)
at cc.spray.RootService$$anonfun$updateHandler$2.apply(RootService.scala:135)
at cc.spray.RootService$$anonfun$updateHandler$2.apply(RootService.scala:135)
at cc.spray.RootService$$anonfun$receive$1.apply(RootService.scala:63)
at cc.spray.RootService$$anonfun$receive$1.apply(RootService.scala:60)
at akka.actor.Actor$class.apply(Actor.scala:478)
at cc.spray.RootService.apply(RootService.scala:30)
at akka.actor.LocalActorRef.invoke(ActorRef.scala:860)
at akka.dispatch.MessageInvocation.invoke(MessageHandling.scala:26)
at akka.dispatch.ExecutableMailbox$class.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:214)
at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.processMailbox(ExecutorBasedEventDrivenDispatcher.scala:120)
at akka.dispatch.ExecutableMailbox$class.run(ExecutorBasedEventDrivenDispatcher.scala:186)
at akka.dispatch.ExecutorBasedEventDrivenDispatcher$$anon$4.run(ExecutorBasedEventDrivenDispatcher.scala:120)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
at akka.dispatch.MonitorableThread.run(ThreadPoolBuilder.scala:181)
The following spec fails when using 0.8.0-SNAPSHOT:
"cache control header is stringified correctly" in {
import cc.spray.http.CacheDirectives._
import cc.spray.http.HttpHeaders._
Cache-Control
(max-age
(0)).toString must beEqual("Cache-Control: max-age=0")
}
As per the HTTP spec: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
Please support scala 2.9.1 in scala-tools.org's maven repository.
Better:
If the file/resource does not exist don't complete the request right away with a 404 response but simply reject it (just like an unmatching path/pathPrefix directive does). This usually creates a proper 404 response on the outermost level but has the additional benefit of giving other routes chained in after the 'getFrom...' directive a chance to act.
This will unify all directives to the FilterRouteX
types and flexibilize route configuration
We've got a problem now where Spray is pulling in Akka 1.1.3 .. but we have a custom build of 1.1.2 ...
Any reason Spray can't use a "provided" scope on the Akka dependency?
See this thread
will make contextual deployment in servlet containers easier
spray 0.5.0 loads a staggering number of classes, some from spray itself and many, many more from parboiled, upon handling of the first request—often enough to take longer than the Akka HTTP timeout. Please do something to preload the classes of spray and its dependencies on startup.
Having said that, spray is brilliant work and I'm loving working with it!
By having routes return a custom phantom type that can only be "constructed" by completing or rejecting a route we can enforce that routes really do complete or reject the request.
This prevents accidental interruption of the request flow through the routing structure...
We probably still need a "swallow" terminator or something, to allow for intential (and explicit!) request swallowing (e.g. for logging).
Hello!
I'm trying to do a test in my project that uses a Rest Interface with authentication. To do the test, I define some interfaces and then I try to connect and it fails because I don't introduce user and password in httpRequest() .
My code is the next:
val mediaType =text/javascript
val expected =
"""
{
"message":"It contains the collection of identifiers of the corpus in the system"
}
"""
testService(HttpRequest(GET, "/corpus", headers = List(`Accept`(mediaType),`Authorization`(httpCredentials)))) {
mapService
}.response.content.as[String] must be(Right(pretty(render(parse(expected)))))
So, I know that I have to specify httpCredentials but I don't know how.
If anyone can explain me how can I do it, I would be so grateful.
Thank you!
see this thread
When I use this code
put {
contentAs[Incasso] {
incasso => {
ctx => ctx.complete(incasso.cust_name)
}
}
} ~
delete {
ctx => ctx.complete("delete")
} ~
get {
ctx => ctx.complete(i)
}
Those directives are wrapped with path() directives.
When I do a PUT and it gets a parse error in the unmarshaller, I always get a HTTP method not allowed and never a MalformedRequestContentRejection. When I remove the above get and delete and only use the put, it works and I get a MalformedRequestContentRejection.
This doesn't look like expected behavior as I would expect the last error to be returned to be the error to find it's way back to the client.
Currently the authentication/authorization infrastructure is synchronous and blocking.
Using a URL of the form:
/someurl?this=that&foo=bar&
... results in a 400 status code and the message "Illegal query string". Looking at the RFC referenced in the Stack Overflow answer (http://stackoverflow.com/questions/6663362/is-a-trailing-ampersand-legal-in-a-url) and with the help of the chosen answer it looks like a trailing ampersand, while pointless, is valid.
We only found this because some of our test frameworks build their query strings lazily but thought you'd like to know.
Many spray applications will also have to query other services.
There are already a few HTTP client library options for Scala developers, however it'd be nice to have one that works directly with sprays existing immutable HTTP model.
The current idea is to provide a very thing layer on top of the excellent AHC library.
In order to enable stand-alone usage we probably need to split spray into separate modules:
Registered HttpServices are currently held as mutable state within the RootService actor.
This needs to be changed in order to support RootService restarts.
Current idea: pass HttpServices as a fixed list to the RootService constructor
You have things for grabbing numbers and such out of the URL in routes. Would be nice to have one for UUIDs as well that creates a java.util.UUID
.
as required by the HTTP 1.1 spec
Otherwise it's hard to supply a custom implicit (Route => Actor) detachedActorFactory
see this thread
One feature that might be interesting to see in the core Spray package would be request throttling. The Piston framework for Django supports this:
https://bitbucket.org/jespern/django-piston/wiki/Documentation#!throttling
If a throttle is hit, then returning a 503 response would be great.
Add support in spray template project for SBT 0.11.0 (migrate)
Version 0.5.0 does not properly handle the charset requirements passed via the requests Accept-Charset header.
spray should marshal text content using a charset that is accepted by the client.
Since scala 2.9.0-1 fixes only some, but some important bugs. I would suggest upgrading akka to the latest 1.1 version, namely 1.1.2 which is build against scala 2.9.0-1. The only change is the scala version, so upgrading should only incorporate changing the version numbers in sbt build configuration.
I receive this Cookie-header from a server, while using spray-client:
rl-sticky-key-0d=9260ee80a1a57d51ad41d580acde1272; path=/;
I lookup the Cookie header parsing bit, and the CookieOctet is missing the '/' character. To fix this it should be like so:
def CookieOctet = rule {
ch('\u0021') | ch('\u002f') | ch('\u0023') - "\u002b" | ch('\u002d') - "\u003a" | ch('\u003c') - "\u005b" | ch('\u005d') - "\u007e"
}
I'm not sure if this may not be an actual bad cookie-header, syntax wise.
I just freshly started on spray, and wanted to run the template / examples projects. The SBT version 0.7.5.RC1 of the master branch, and 0.7.7 of the develop branch, seems to be no longer available from the default public repositories. Does anyone still have it around?
I understand that switching to SBT 0.10.0 would be an undertaking, giving that the plugin structure seems to have been completely changed (from what I can see at quick glance)
Provide the ability for marshallers and unmarshallers to be registered not only for the request's content type but also for a particular URI match.
Sometimes, a single service may need to produce different message structures for the same operation. That is, a message format would need to be upgraded or changed, but the old message structure should still be supported through a different URI. It would be useful if you can register different marshallers / unmarshallers for different versions of a service with the version being specified in the URI.
For example, the twitter API has a version number included in the beginning of the URI path.
https://api.twitter.com/1/statuses/show/1234566.json
The Twitter API version above is 1, included as the first part of the URI.
The appropriate marshaller or unmarshaller would be chosen according to the version.
You cannot currently register the appropriate marshaller/unmarshaller according to the URI path in Spray.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.