Created
July 20, 2018 00:21
-
-
Save ehoner/538526dcc02fecf0143f8f87f49f7e8f to your computer and use it in GitHub Desktop.
Reproduction errors in http4s related to http4s/http4s/issues/1256. Requires running local web server, instructions and configuration for nginx are included.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Reproduce errors for http4s. Some assembly is required. Most of this | |
can be done with brew. These instructions use nginx (webserver) with | |
the embedded configuration. Backup any existing nginx.conf. | |
NOTE: Test expects nginx to listent to port 80 - requires root privileges. | |
ie. $ sudo brew services restart nginx | |
#1 install nginx ($ brew install nginx) | |
#2 create nginx configuration using command below or copy and paste | |
to /usr/local/etc/nginx/nginx.conf | |
$ cat - >| /usr/local/etc/nginx/nginx.conf <<'EOF' | |
worker_processes 1; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
'$status $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for"'; | |
access_log /usr/local/var/log/nginx/access.log main; | |
include mime.types; | |
default_type application/octet-stream; | |
sendfile on; | |
keepalive_timeout 65; | |
server { | |
listen 80; | |
location / { | |
alias /usr/local/var/www/; | |
} | |
} | |
} | |
EOF | |
#3 Add test file to document root of webserver | |
$ curl -so /usr/local/var/www/kml21.xsd https://developers.google.com/kml/schema/kml21.xsd | |
#4 start http4s server with ammonite. (brew install ammonite-repl) | |
$ amm http4s | |
#5 After ammonite is running observe the logs and make several curl requests. | |
Normally, by the the fourth request the server will report errors. | |
$ curl -sv -o /dev/null --http1.0 localhost:8080/kml21.xsd | |
*/ | |
// using ammonite start an http server to proxy requests to local webserver | |
import $ivy.`ch.qos.logback:logback-classic:1.2.3` | |
import $ivy.`org.http4s::http4s-dsl:0.18.15` | |
import $ivy.`org.http4s::http4s-blaze-server:0.18.15` | |
import $ivy.`org.http4s::http4s-blaze-client:0.18.15` | |
import cats.effect.IO | |
import org.http4s.client.blaze.Http1Client | |
import org.http4s.server.blaze.BlazeBuilder | |
import scala.concurrent.ExecutionContext.Implicits.global | |
Http1Client.stream[IO]().flatMap { client => | |
BlazeBuilder[IO] | |
.bindHttp(8080, "127.0.0.1") | |
.mountService(client.toHttpService, "/") | |
.serve | |
}.compile.drain.unsafeRunSync |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment