Book Image

RESTful Java Web Services, Second Edition

Book Image

RESTful Java Web Services, Second Edition

Overview of this book

Table of Contents (17 chapters)
RESTful Java Web Services Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Overriding HTTP methods


Due to security reasons, some corporate firewalls (HTTP proxies) support only the POST and GET methods. This restriction forces a REST API client to use only those HTTP methods that are allowed through the firewall. RESTful web API implementations can work around this restriction by letting the client override the HTTP method via the custom X-HTTP-Method-Override HTTP header. The REST API client can specify an X-HTTP-Method-Override request header with a string value containing either PUT, PATCH, or DELETE. When the server gets the request, the server replaces the POST method call with the method string value set for X-HTTP-Method-Override.

JAX-RS allows you to implement this behavior via prematching javax.ws.rs.container.ContainerRequestFilter. To learn more about ContainerRequestFilter, refer to the Understanding filters and interceptors in JAX-RS section in Chapter 4, Advanced Features in the JAX-RS API.

//Other imports are omitted for brevity
import javax.ws.rs...