Search in sources :

Example 6 with ResponseBuilder

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

the class ResponseTest method getDate.

@POST
@Path("date")
public Response getDate(String date) throws InterruptedException {
    ResponseBuilder builder = Response.ok();
    Thread.sleep(1500L);
    if (date != null && date.length() != 0) {
        long millis = Long.parseLong(date);
        Date dateFromMillis = new Date(millis);
        builder = builder.header(HttpHeaders.DATE, 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 7 with ResponseBuilder

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

the class ResponseTest method getAllowedMethods.

@POST
@Path("allowedmethods")
public Response getAllowedMethods(String methods) {
    ResponseBuilder builder = Response.ok();
    StringTokenizer tokenizer = new StringTokenizer(methods);
    List<String> allowed = new LinkedList<String>();
    while (tokenizer.hasMoreTokens()) allowed.add(tokenizer.nextToken());
    builder.allow(allowed.toArray(new String[0]));
    return builder.build();
}
Also used : StringTokenizer(java.util.StringTokenizer) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) LinkedList(java.util.LinkedList) Path(jakarta.ws.rs.Path) POST(jakarta.ws.rs.POST)

Example 8 with ResponseBuilder

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

the class Resource method getLink.

@POST
@Path("getlink")
public Response getLink(String uri) {
    ResponseBuilder builder = createResponseWithHeader();
    if (uri != null && uri.length() != 0) {
        Link link = Link.fromUri(uri).rel(ResponseFilter.RELATION).build();
        builder = builder.links(link);
    }
    Response response = builder.build();
    return response;
}
Also used : Response(jakarta.ws.rs.core.Response) ResponseBuilder(jakarta.ws.rs.core.Response.ResponseBuilder) Link(jakarta.ws.rs.core.Link) Path(jakarta.ws.rs.Path) POST(jakarta.ws.rs.POST)

Example 9 with ResponseBuilder

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

the class Resource method setEntityStream.

@GET
@Path("setentitystream")
public Response setEntityStream() {
    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)

Example 10 with ResponseBuilder

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

the class Resource method setEntity.

@GET
@Path("setentity")
public Response setEntity() {
    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