Telegraph icon indicating copy to clipboard operation
Telegraph copied to clipboard

HEAD method doesn't seem to work

Open osfunapps opened this issue 2 years ago • 1 comments
trafficstars

Hello,

I have this simple code to handle head requests:

func startServer(port: Int) -> Error? {
        do {
            if server.isRunning {
                return nil
            }
            
            try server.start(port: port)
            server.webSocketDelegate = self
            server.route(.HEAD, "head", handleHeadRequest(request:))
            return nil
        } catch let error {
            if error.localizedDescription == "Address already in use" {
                return nil
            }
            return error
        }
    }

   func handleHeadRequest(request: HTTPRequest) -> HTTPResponse {
      return HTTPResponse(content: "Hello")
    }

For some reason, I don't receive any requests from the server side.

Can you help me?

osfunapps avatar Apr 10 '23 09:04 osfunapps

I am also having issue with HEAD route... in unit test when I issue HEAD http request towards Telegraph's HEAD route... e.g. telegraph.route(.HEAD, regex: ".*") { request in HTTPResponse(.ok) }

Every HEAD request fails with error: "Network connection was lost" Every other HTTP method I put in that route (PUT, PATCH) works - only HEAD is failing

rssole avatar Oct 18 '23 21:10 rssole

This should be resolved in the latest commits

yvbeek avatar Mar 31 '24 23:03 yvbeek