Skip to content
Advertisement

Tag: http

Spring RestTemplate getForObject getting 404

I’m trying to make a get request to an Api Rest but I’m always getting 404, nevertheless if try copying queryUrl in a browser or postMan it works perfectly. restTemplate.getForObject(queryUrl, entity ,Integer.class); I’ve also tried this: HttpHeaders httpHeaders = new HttpHeaders(); httpHeaders.setContentType(MediaType.APPLICATION_JSON); HttpEntity entity = new HttpEntity(httpHeaders); log.debug(“request headers: ” + entity.getHeaders()); ResponseEntity response = restTemplate.exchange(queryUrl, HttpMethod.GET, entity, String.class); But

Enable HTTP2 with Tomcat in Spring Boot

Tomcat 8.5, which will be the default in Spring Boot 1.4, supports HTTP/2. How can HTTP/2 be enabled in a Spring Boot application? Answer The most elegant and best-performing way to enable HTTP/2 with a Spring Boot application follows here. First, as mentioned in Andy Wilkinson’s answer, you need to enable HTTP/2 at Tomcat level: In case you are not

Groovy HTTP ResponseParseException not found

I am trying to make simple GET request using groovy HTTP request. I am expecting JSON response in this form: So far I have done this in my code: and I am always getting this response: I have googled and found out that it’s problem related to groovy and this problem was not occurring before version 2.3.0, like this post

In Java servlet, cookie.getMaxAge() always returns -1

If I set a cookie with a setMaxAge() well into the future, when I read the cookie back into memory in a subsequent request, the getMaxAge() gives me back a -1. I have checked the actual cookie via Chrome’s settings, and inspector, and I can verify that the expiration date is indeed set 60 days in the future. Why does

Parsing RTSP stream for live radio

I want to be able to parse the rtsp stream in order to extract data about the radio station, current playing song name, duration etc. I have to do it manually – no libraries. Preferred language is Java but I could work with something else too. Answer Welcome to the world of RFC 2326: Real Time Streaming Protocol (RTSP). You’ll

Returning ZipOutputStream to browser

I have an ZipOutputStream that I want to return to the browser. The experience I would like is that the user clicks an anchor tag, and then a file download prompt is displayed for the ZipOutputStream that I have. How do you get the ZipOutputStream back to the browser? Answer Just had to do this exact same thing yesterday. Note

Get page content from Apache Commons HTTP Request

So I’m using Apache Commons HTTP to make a request to a webpage. I cannot for the life of me figure out how to get the actual content from the page, I can just get its header information. How can I get the actual content from it? Here is my example code: Answer Use HttpResponse#getEntity() and then HttpEntity#getContent() to obtain

Preferred Java way to ping an HTTP URL for availability

I need a monitor class that regularly checks whether a given HTTP URL is available. I can take care of the “regularly” part using the Spring TaskExecutor abstraction, so that’s not the topic here. The question is: What is the preferred way to ping a URL in java? Here is my current code as a starting point: Is this any

Advertisement