Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

189
Visualizações
How to implement the response to the TRACE request in express.js?

The HTTP TRACE method performs a message loop-back test along the path to the target resource, providing a useful debugging mechanism. The final recipient of the request should reflect the message received back to the client as the message body of a 200 (OK) response with a Content-Type of message/http.

Example of an HTTP request with the TRACE method:
enter image description here

Example of a response to a request with the TRACE method:
enter image description here

const path = require( 'path' );
const express = require( 'express' );      // version 4.x
const favicon = require( 'serve-favicon' );

const app = express();

app .use( favicon( path.join( __dirname, 'assets', 'logo.ico' ) ) );

app.trace( '*', ( req, res ) => {
  // how do I return the entire request in its original form in response?
} );
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

The request argument in Express is actually a modified node.js http.IncomingMessage object so you can get all the request data from it:

app.trace( '*', ( req, res ) => {
    res.end(
        `${req.method} ${req.url} HTTP/${req.httpVersion}\r\n` +
        req.rawHeaders.join('\r\n')
    )
});

This would generally re-create the request but because you are reconstructing it instead of simply copying it there may be small differences.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda