Skip to content

How to use this with Firefox #17

@veso266

Description

@veso266

Hi there, was wondering, if you were ever able to make this work on Mozilla Firefox

For the love of me I cannot find a single http2 server in C# that works in firefox

I know this implementation works: https://github.com/GoogleChromeLabs/simplehttp2server/tree/master

but nothing I was able to find in C# works in firefox

I even tried curl like this:

curl --insecure -I --http2 https://domain.local

and this is what curl had to say about it (the server does respond, but only with http 1.1 part, not http2)

HTTP/1.1 204 No Content
Server : prosjekthttp2

my plan is to integrate this into NetCoreServer if I am ever able to make it work: https://github.com/chronoxor/NetCoreServer

My example server looks like this (the certificate is signed by CA that firefox trusts, so there should be no issues there)

using System;
using System.IO;
using System.Security.Cryptography.X509Certificates;
using lib;

namespace ExampleServer
{
    class Program
    {
        static void Main(string[] args)
        {
            //Console.BufferHeight = short.MaxValue-1;

            //Creating the certificate
            var serverCertificate = new X509Certificate2("Certificate/domain.pfx", "qwerty");
            //Creating the server
            Server server = new Server("192.168.88.12", serverCertificate);
                       

            //test Get method
            server.Get("testurl", (req, res) => {
                res.Send("get from test url");
            });

            //test Post method
            server.Post("testurl", (req, res) => {
                res.Send($"post from test url, {req.BodyAsString()}");
            });

            //test sending JSON object
            server.Get("jsonobject", (req, res) =>
             {
                 res.Send("{ \"name\":\"Jone\", \"age\":39, \"car\":null }");
             });

            //test Path Variable
            server.Get("artikler/:kategori/artikkelid", (req, res) =>
            {
                int artikkelID = Int32.Parse(req.Params["artikkelid"]);
                string kategori = req.Params["kategori"];
                res.Send(Database.HentArtikkelFraDatabase(kategori, artikkelID));
            });

            server.Use("WebApp");
            //Server.UseGZip = false;
            //Server.UseDebugDirectory = true;
           
            //Server starts listening to port, and responding to webpage.
            server.Listen(443);


        }
        private static class Database
        {
            public static string HentArtikkelFraDatabase(string kategori, int artikkelID)
            {
                return $"Dette er artikkel #{artikkelID} i kategorien {kategori}, fersk fra databasen";
            }
        }
    }
}

The server works, but for some reason not HTTP2 part, the server always responds with HTTP 1.1
slika

I use this addon: https://addons.mozilla.org/sl/firefox/addon/http-indicator/

that tells me its only HTTP 1.1

Not sure whats going on here
I also tried this: https://github.com/mynyml/http2server (quits imidiatly)
this: https://github.com/MatthewSmit/Http2Sharp
and even this: https://github.com/mynyml/http2server

nothing works, and for the love of me, I cannot figure out why

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions