I need to make a POST call with a content-length equal to 0. So I tried setting the header to 0 when I make the call but in the web service that receives the call the content-length is much greater than 0.
Request
let url = '/blah/blah/'+ anUID +'/blah/' + anotherUID + '';
let headers = new Headers({'Content-Length': '0'});
let options = new RequestOptions({
method: RequestMethod.Post,
headers: headers,
});
return this.http.post(url, options)
.map(this.extractData)
.catch(this.handleError.bind(this));
The on in the receiving web service there is a check to make sure that the request's content length is 0.
@POST
@Produces(MediaType.APPLICATION_JSON)
@Path("{anUID}/blah/{anotherUID}")
public Response myWebService(@PathParam("anUID") Integer anUID, @PathParam("anotherUID") Integer anotherUID,
@Context ServletContext application, @Context HttpServletRequest request, @Context UriInfo info) {
Response resp = Response.notModified().build();
String method = request.getMethod(); // == "POST"
int meh = request.getContentLength(); // = 172 NEEDS TO BE 0
if (request.getContentLength() < 1) {
...
}
...
}
What could I do differently to set the content-length equal to 0?