Search in sources :

Example 66 with ResponseBuilder

use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.

the class ReturnTypeTest method nullEntityResponse.

@GET
@Path("nullEntityResponse")
public Response nullEntityResponse() {
    RuntimeDelegate rd = RuntimeDelegate.getInstance();
    ResponseBuilder rb = rd.createResponseBuilder();
    return rb.entity(null).build();
}
Also used : ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) RuntimeDelegate(jakarta.ws.rs.ext.RuntimeDelegate) Path(jakarta.ws.rs.Path) GET(jakarta.ws.rs.GET)

Example 67 with ResponseBuilder

use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.

the class ResponseTest method getHeaders.

@POST
@Path("headers")
public Response getHeaders(String headers) {
    CacheControl ccl = new CacheControl();
    NewCookie cookie = new NewCookie("cookie", "eikooc");
    String encoding = "gzip";
    Date date = Calendar.getInstance().getTime();
    ResponseBuilder builder = Response.ok();
    if (headers != null && headers.length() != 0) {
        builder = builder.cacheControl(ccl).cookie(cookie).encoding(encoding).expires(date).language(Locale.CANADA_FRENCH);
    }
    return builder.build();
}
Also used : CacheControl(jakarta.ws.rs.core.CacheControl) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Date(java.util.Date) NewCookie(jakarta.ws.rs.core.NewCookie) Path(jakarta.ws.rs.Path) POST(jakarta.ws.rs.POST)

Example 68 with ResponseBuilder

use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.

the class ResponseTest method getLanguage.

@POST
@Path("language")
public Response getLanguage(String lang) {
    ResponseBuilder builder = Response.ok();
    Locale locale = null;
    if (Locale.CANADA_FRENCH.getCountry().equals(lang))
        locale = Locale.CANADA_FRENCH;
    if (locale != null)
        builder = builder.language(locale);
    return builder.build();
}
Also used : Locale(java.util.Locale) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Path(jakarta.ws.rs.Path) POST(jakarta.ws.rs.POST)

Example 69 with ResponseBuilder

use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.

the class ResponseTest method lastModified.

@POST
@Path("lastmodified")
public Response lastModified(String date) {
    ResponseBuilder builder = Response.ok();
    if (date != null && date.length() != 0) {
        long millis = Long.parseLong(date);
        Date dateFromMillis = new Date(millis);
        builder = builder.lastModified(dateFromMillis);
    }
    Response response = builder.build();
    return response;
}
Also used : Response(jakarta.ws.rs.core.Response) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Date(java.util.Date) Path(jakarta.ws.rs.Path) POST(jakarta.ws.rs.POST)

Example 70 with ResponseBuilder

use of jakarta.ws.rs.core.Response.ResponseBuilder in project jaxrs-api by eclipse-ee4j.

the class Resource method getEntityStream.

@GET
@Path("getentitystream")
public Response getEntityStream() {
    ResponseBuilder builder = createResponseWithHeader();
    Response response = builder.build();
    return response;
}
Also used : Response(jakarta.ws.rs.core.Response) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Path(jakarta.ws.rs.Path) GET(jakarta.ws.rs.GET)

Aggregations

ResponseBuilder (jakarta.ws.rs.core.Response.ResponseBuilder)80 Response (jakarta.ws.rs.core.Response)69 Path (jakarta.ws.rs.Path)41 Test (org.junit.jupiter.api.Test)34 POST (jakarta.ws.rs.POST)27 GET (jakarta.ws.rs.GET)14 Date (java.util.Date)6 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Annotation (java.lang.annotation.Annotation)4 VerificationResult (ee.jakarta.tck.ws.rs.api.rs.core.responseclient.VerificationResult)3 StringBean (ee.jakarta.tck.ws.rs.common.provider.StringBean)3 NewCookie (jakarta.ws.rs.core.NewCookie)3 RuntimeDelegate (jakarta.ws.rs.ext.RuntimeDelegate)3 IOException (java.io.IOException)3 StringBeanWithAnnotation (ee.jakarta.tck.ws.rs.common.provider.StringBeanWithAnnotation)2 Produces (jakarta.ws.rs.Produces)2 WebApplicationException (jakarta.ws.rs.WebApplicationException)2 EntityTag (jakarta.ws.rs.core.EntityTag)2 Link (jakarta.ws.rs.core.Link)2 InputStreamReader (java.io.InputStreamReader)2