http

How to use `curl` scripts to test RESTful web services alvin May 1, 2019 - 7:08am

There may be better ways to do this, but when I was writing a mobile app, with the JavaScript client written in Sencha Touch and the server written with the Play Framework, I wrote some curl scripts to simulate GET, POST, DELETE, and PUT request (method) calls to my Play Framework REST/RESTful web services.

Diagrams that explain HTTP and HTTP2 alvin July 30, 2018 - 6:51pm

Here are three nice diagrams drawn by Mariko Kosaka that explain HTTP and HTTP2.

sttp, a Scala HTTP client alvin July 15, 2018 - 1:07pm

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.

Reading Play Framework HTTP request headers (examples)

If you ever need to work with HTTP request headers in a Play Framework application, I hope the following examples will help. I was just looking at trying to access request headers like “User-Agent” and “Referer,” and ran a few tests.

Note: I put all of the Scala code that follows in Play Framework controller actions, then accessed the URL that was associated with those actions in the Play routes file, using the latest version of the Firefox browser on a MacOS system.

How do I set the Play Framework 2.6 port in production mode? alvin April 4, 2018 - 3:17pm

Play Framework FAQ: How do I set the Play Framework 2.6 port in production mode?

You set the port that your Play Framework application listens on by passing the http.port parameter to the “run” script for your application:

-Dhttp.port=5150

Here’s an example of a command I use to execute the run script for a Play Framework application named myapp:

HTTPS for everyone alvin July 23, 2017 - 1:17pm

July 22, 2017 will go down as the day I (finally) switched this website to using HTTPS instead of HTTP. (See the padlock icon in the URL field of your browser.) I’ve been using a self-signed certificate to log in to this site for a long time, but yesterday I finally switched to “HTTPS for everyone.”

How to use `curl` to get headers from a URL

Curl FAQ: How do I use curl to get the headers from a website URL?

Short answer: Use curl's -I option, like this:

$ curl -I URL

Here's a specific example, including a real URL and results:

ScalaJ-HTTP examples: GET, POST, handling redirects alvin November 22, 2016 - 4:34pm
Table of Contents1 - Handling redirect requests with ScalaJ-HTTP2 - ScalaJ-HTTP GET request example3 - Setting ScalaJ-HTTP timeout values4 - A ScalaJ-HTTP POST request example5 - ScalaJ-HTTP: Summary

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.