Comments (5)
Oops: I didn't think far enough ahead to try my example with a browser; it looks like the newline issue is curl's fault, not gocraft/web's. In Firefox, the above example works unmodified.
If you could answer the second question Re: long-running requests we can close this out :)
from web.
@kofalt to be honest I think this could be used to implement an SSE-type of thing, but I've never done it. There's also packages like this for SSE: https://github.com/antage/eventsource. It would be pretty easy to use that with gocraft/web with a small wrapper.
from web.
Hmm, fair enough. I did notice that when I modified my example thus:
func (c *Context) SayHello(rw web.ResponseWriter, req *web.Request) {
Println("Running handler")
for n := 1; n < 10; n++ {
Fprint(rw, strings.Repeat("Hello ", c.HelloCount), "World!\n")
rw.Flush()
time.Sleep(1 * time.Second)
}
Fprint(rw, strings.Repeat("Hello ", c.HelloCount), "World!\n")
}
And made multiple requests at the same time, each would block until the previous request had finished. The Running handler
messages only printed one at a time also.
This gives the appearance of gocraft/web only handling one request at a time; thoughts?
from web.
@kofalt I think Firefox only sends 1 request at a time. Try using firefox + chrome.
from web.
You're absolutely right. How embarassing. This appears to be unaffected by Firefox's network.http.max-connections-per-server
setting (possibly because it's the same URL).
Notably, Chrome won't print any output until the mesage is done, so instead by using Firefox & curl, or multiple runs of curl, the correct behavior can be observed.
Thanks for your help getting started :)
from web.
Related Issues (20)
- Comment for OptionsHandler is wrong (copy-paste error) HOT 1
- The router setup is not race safe
- subrouter middleware chaining HOT 1
- go vet warnings
- websocket support HOT 2
- Is gocraft/web compatible with standard http.Handlers? HOT 1
- Tag Versions?
- context with request and response
- Multiple domains and subdomains HOT 2
- proposal: sitemap.xml generator
- fasthttp support
- Subrouter middleware does not get called if no valid route requested HOT 1
- File upload not working HOT 1
- Impossible to get value of query params HOT 1
- Function Signatures
- Header change not honored after middleware set it
- Can you replace a route?
- Can you make public accessor to pathPrefix of a Router?
- url with trailing slash match route Get("/test/:uid" should be 404
- Nm634
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from web.