sttp, a Scala HTTP client
I haven’t tried it yet, but if you’re interested in a Scala HTTP client, the people at softwaremill.com have sttp, and its docs are here.
I haven’t tried it yet, but if you’re interested in a Scala HTTP client, the people at softwaremill.com have sttp, and its docs are here.
This is a page from my book, “A Survival Guide for New Consultants”
“When we do not expect anything we can be ourselves. That is our way, to live fully in each moment of time.”
This is a page from my book, “A Survival Guide for New Consultants”
This is a page from my book, “A Survival Guide for New Consultants”
“When you can do nothing, what can you do?”
As I’ve mentioned, you’re hired to be a consultant because you’re a problem-solver, so it really hurts when you can’t help a client. It’s a tough lesson, but it’s an important one:
Despite your best efforts,
you can’t always save the client.
As a quick note, I haven’t tried to log into one of my GoDaddy websites in several months, and when I tried to log in just now I got this macOS ssh error message:
Unable to negotiate with <ip-address here> port 22: no matching host key type found. Their offer: ssh-dss
If you ever need some good ScalaJ-HTTP examples, see the test files in the project, including this HttpBinTest.scala file. That file currently shows a number of good ScalaJ-HTTP examples, including GET, POST, redirect examples with Scala.
See that page for a full list of examples, but for my own use, here are a few of them.
If for some reason you ever want to print out some HTTP response headers from a HEAD
request when using ScalaJ-HTTP as an HTTP client, this example may help point you in the right direction:
import scalaj.http._ object TestHead extends App { val response: HttpResponse[String] = Http("http://www.google.com") .method("HEAD") .timeout(connTimeoutMs = 2000, readTimeoutMs = 5000) .asString for ((k,v) <- response.headers) println(s"key: $k\nvalue: $v\n") }
I may write more about ScalaJ-HTTP in the future, but for today that’s a quick example of processing the response headers/parameters when making a HEAD request.
The new Gigahorse 0.1.0 page states that it is “an HTTP client for Scala with Async Http Client underneath.”
Summary: This post is an excerpt from the Scala Cookbook, partially modified for the internet. This is a short recipe, Recipe 15.13, “How to set HTTP headers when sending a web service request.”
You need to set URL headers when making an HTTP request in Scala.