fess
fess copied to clipboard
Improve CORS functionality implementation
This commit improves the CORS (Cross-Origin Resource Sharing) implementation in the org.codelibs.fess.cors package with the following enhancements:
-
Bug Fixes:
- Fixed typo in CorsHandlerFactory: renamed 'handerMap' to 'handlerMap'
- Changed OPTIONS preflight response from SC_ACCEPTED (202) to SC_OK (200) for better compliance with CORS standard
-
Thread Safety:
- Replaced HashMap with ConcurrentHashMap in CorsHandlerFactory
- Added thread-safety documentation
-
New Features:
- Added Access-Control-Expose-Headers support to expose custom headers
- Added Vary: Origin header for proper caching behavior
- Added Access-Control-Allow-Private-Network support for private network access requests (Chrome feature)
-
Configuration:
- Added new config property: api.cors.expose.headers
- Added corresponding method in FessConfig interface
- Updated default values and documentation
-
Code Quality:
- Added inline comments for better code readability
- Added new header constants in CorsHandler base class
- Improved JavaDoc documentation
-
Tests:
- Updated CorsHandlerFactoryTest to use correct field name
- Updated CorsFilterTest to expect SC_OK instead of SC_ACCEPTED
These improvements enhance security, performance, and standards compliance of the CORS implementation while maintaining backward compatibility.