I am trying to fetch some files from internet. I want to update my schedule service if the last modified time update. With HTTPBuilder I am unable to find the server response with last-modified parameter. Is there any way to get this parameter?
Asked
Active
Viewed 1,253 times
1 Answers
3
As in the docs Last-Modified
is a header and should be searched among other headers. What's important is that it's server that decides if Last-Modified
header will be included in the response. Hence, if the server you connect to doesn't return the header in the response it's impossible to get the value.
Headers can be obtained via response
object, see below:
@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.7.1')
import groovyx.net.http.HTTPBuilder
import static groovyx.net.http.Method.GET
import static groovyx.net.http.ContentType.TEXT
def http = new HTTPBuilder( 'http://www.google.com/search' )
http.request(GET,TEXT) { req ->
response.success = { res ->
res.headers.each { h ->
println h
}
}
}

Opal
- 81,889
- 28
- 189
- 210
-
Dear Opal my server returning this header how to get it. How to get headers? – Cool Java guy מוחמד Apr 19 '16 at 01:06
-
@JavaGeek, if you found my answer helpful please accept and upvote it. – Opal Apr 28 '16 at 12:44