How do I get the Content-Type of the response from WS.url().get() in Play java

StackOverflow https://stackoverflow.com/questions/22955079

  •  30-06-2023
  •  | 
  •  

سؤال

I am making a Web service call from Java Play framework. Below is the code.

WS.url(url).get().map(
    new F.Function<WS.Response, Result>() {
         @Override
         public Result apply(WS.Response response) throws Throwable {
              return ok(response.getBody())
         }
    }
);

How do I return the content type as the content type of the WS.Response ?

هل كانت مفيدة؟

المحلول

I think it should be:

     @Override
     public Result apply(WS.Response response) throws Throwable {
          return ok(response.getBody()).as(response.getHeader("Content-Type"));
     }
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top