Search code examples
httpwebtelnet

How to get web page xml content using Telnet


How can I get the xml content from the following website using telnet:

http://www.musicbrainz.org/ws/2/artist/?query=artist:fred

This is what I tried:

telnet www.musicbrainz.org 80
GET /ws/2/artist/?query=artist:fred

This is what I get:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
  <head>
    <title>403 Forbidden</title>
    <link rel="stylesheet" href="/.proxy/httperror.css" type="text/css" />
  </head>
  <body>
    <div id="bg">
      <img src="/.proxy/MusicBrainzLogo-stop.png" />
    </div>
    <h1>Forbidden</h1>
    <p>Nothing for you to see here.&nbsp; Please move along.</p>
    <p id="http">403 Forbidden</p>
  </body>
</html>
Connection closed by foreign host.

Does this mean I am not allowed to retrieve the content or I am doing something wrong ?


Solution

    1. add " HTTP/1.1" to the request line

    2. fix the spelling mistake in the query

    3. add a host header field ("host: www.musicbrainz.org")

    (see https://greenbytes.de/tech/webdav/rfc7230.html#operation for an example message)