spring-cloud / spring-cloud-netflix

Integration with Netflix OSS components
http://cloud.spring.io/spring-cloud-netflix/
Apache License 2.0
4.87k stars 2.44k forks source link

[Zuul Proxy] For HTTP Method "REPORT" post data is not passing to CalDav service. #1865

Closed ashishpratapsingh14 closed 7 years ago

ashishpratapsingh14 commented 7 years ago

For HTTP Method "REPORT" post data is not passing to service. While I am hitting service directly it's responding as expected.

spencergibb commented 7 years ago

Please provide more details. As it stands we don't have enough information to help

ashishpratapsingh14 commented 7 years ago

I am using URL based routeing configuration to my Service Which uses "REPORT" method with post body. Which means it's going to use SimpleHostRoutingFilter. And it's not sending any post body in case of "REPORT" type method.

ryanjbaxter commented 7 years ago

We don't handle the REPORT HTTP method in SimpleHostRoutingFilter.
https://github.com/spring-cloud/spring-cloud-netflix/blob/master/spring-cloud-netflix-core/src/main/java/org/springframework/cloud/netflix/zuul/filters/route/SimpleHostRoutingFilter.java#L318

You could provide your own filter to modify the request further and forward on the body.

ashishpratapsingh14 commented 7 years ago

I handle it this way...

@Component
public class CustomBeanPostProcessor implements BeanPostProcessor {

...
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        logger.debug("[CUSTOM_DEBUG] CustomBeanPostProcessor.postProcessBeforeInitialization() [beanName:: "+beanName+"]");
        if(SimpleHostRoutingFilter.class.isAssignableFrom(bean.getClass())){
            return new CustomHostRoutingFilter(helper, zuulProperties);
        }
        return bean;
    }
...
}

is it correct way to do?

ryanjbaxter commented 7 years ago

I was thinking you could add your own ZuulFilter the does something similar to SimpleHostRoutingFilter for the REPORT method.

spencergibb commented 7 years ago

REPORT isn't a standard HTTP method, so I'm not sure this warrants an enhancement. https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html. It's specific to webdav http://ietf.org/rfc/rfc3253.

ryanjbaxter commented 7 years ago

I can buy that, I didnt even know it existed till I saw this issue :) I looked it up and read what it was used for but didnt think to look any further.

ashishpratapsingh14 commented 7 years ago

I tried doing that only but I was not able to stop executing SimpleHostRoutingFilter After my filter runs that's why I replaced it with following code.

public class CustomHostRoutingFilter extends SimpleHostRoutingFilter {

...

    @Override
    protected HttpRequest buildHttpRequest(String verb, String uri, InputStreamEntity entity,
            MultiValueMap<String, String> headers, MultiValueMap<String, String> params) {
        HttpRequest httpRequest;

        switch (verb.toUpperCase()) {
            case "REPORT":
                HttpReport httpReport = new HttpReport(uri + this.helper.getQueryString(params));
                httpRequest = httpReport;
                httpReport.setEntity(entity);
                httpRequest.setHeaders(convertHeaders(headers));
                return httpRequest;
            default:
                return super.buildHttpRequest(verb, uri, entity, headers, params);
        }
    }

...

}
ryanjbaxter commented 7 years ago

That is another option as well. I am going to close this issue for now. If we see a high demand for supporting REPORT than we can discuss it again.