dhttpd icon indicating copy to clipboard operation
dhttpd copied to clipboard

Add support for header files.

Open Alejandro-FA opened this issue 1 year ago • 0 comments

Description

The current option for customizing response headers is very limited, as demonstrated by #63 and #22. This pull request adds the possibility of specifying path-specific headers using a file (with the new --headersfile option).

Design

The goal is to enable the possibility of testing complex headers behavior in a local environment. To this end, I have focused on adding support for two "real-world" header file formats:

Each of these formats uses a glob pattern-mathing system to specify the paths to which the headers should be applied. Additional file formats could be added in the future with minimal effort.

Additional notes

  • I have added a new dependency to the project: glob. This package is used to match the paths in the header files.
  • I have added a new test: headers_test.dart. It tests header parsing.
  • I have added two example header files: sample/_headers and sample/headers.json. These files are also used in the tests.
  • I have taken the liberty of including PR #63, as it is a very small change and it is closely related.

Alejandro-FA avatar Sep 27 '24 02:09 Alejandro-FA