client

MacOS/GoDaddy ssh error: Unable to negotiate, no matching host key type found, their offer alvin November 24, 2016 - 3:00pm

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

How to create a Scala Twitter client using ScalaJ-HTTP and HTMLCleaner

Here’s some Scala source code that shows how to scrape the tweets off of a Twitter page. I was thinking about rewriting a Twitter module I use to use a “pure HTML” approach, and the test/demo code I came up with looks like this:

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

Processing HTTP response headers with a ScalaJ-HTTP web client alvin September 11, 2016 - 10:23pm

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.

How to set HTTP headers when sending a web service request

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.”

Problem

You need to set URL headers when making an HTTP request in Scala.

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

How to access HTTP response headers after making an HTTP request with Apache HttpClient

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is a very short recipe, Recipe 15.12, “How to access HTTP response headers after making an HTTP request with Apache HttpClient.”

Problem

You need to access the HTTP response headers after making an HTTP request in your Scala code.

Solution

Use the Apache HttpClient library, and get the headers from the HttpResponse object after making a request:

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

How to create a Twitter client in Scala

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 15.10, “How to create a Twitter client in Scala.”

Problem

You want to create a client to connect to Twitter to access the information you want, such as showing timelines and trends.

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.

How to write a simple HTTP GET request client in Scala (with a timeout)

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 15.9, “How to write a simple HTTP GET request client in Scala.”

Back to top

Problem

You want an HTTP client you can use to make GET request calls.

Back to top

Solution

There are many potential solutions to this problem. This recipe demonstrates three approaches:

Table of Contents

  1. Problem
  2. Solution
Back to top

Share it!

There’s just one person behind this website; if this article was helpful (or interesting), I’d appreciate it if you’d share it. Thanks, Al.