http-server icon indicating copy to clipboard operation
http-server copied to clipboard

Add content-type for rendered pages generated by "http-server"

Open patrickdappollonio opened this issue 2 years ago • 0 comments

From a person using this: after using HTTrack to get a static copy of a website served by http-server, they noticed the content-type meta tag was not present, so httrack added one.

I confirmed this by running it myself:

<!doctype html>

<html lang="en">

<!-- Mirrored from localhost:9000/ by HTTrack Website Copier/3.x [XR&CO'2014], Wed, 28 Jun 2023 00:12:58 GMT -->
<!-- Added by HTTrack --><meta http-equiv="content-type" content="text/html;charset=utf-8" /><!-- /Added by HTTrack -->
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <meta name="generator" content="github.com/patrickdappollonio/http-server development">
  <meta name="theme-color" content="#3f51b5">
  <title>HTTP File Server</title>
  <link rel="stylesheet" href="_/s8jhp0b1/assets/style.css">
  <link rel="stylesheet" href="_/s8jhp0b1/assets/roboto-font.css">
  <link rel="stylesheet" href="_/s8jhp0b1/assets/fontawesome-6.2.0.css">
  <link rel="icon" type="image/svg+xml" href="_/s8jhp0b1/assets/file-server.svg">
  <link rel="stylesheet" href="_/s8jhp0b1/assets/gfm.css">
</head>

We'll need to add the header. While the Go standard library will do content type hinting, it's better if we set this ourselves. Even more so for non-western languages.

patrickdappollonio avatar Jun 28 '23 00:06 patrickdappollonio