I am trying to use inetc::put
to upload a Styled Layer Descriptor (.sld) to a local GeoServer instance that has a RESTful endpoint. I get an error saying I need to set the Content-type, even though I am.
inetc::put /silent /header "Content-type: application/vnd.ogc.sld+xml" "http://username:password@localhost:8080/geoserver/rest/styles/MyNewStyle" "$INSTDIR/MyNewStyle.sld"
Pop $0
DetailPrint "Uploading styled layer descriptor: $0"
This returns an HTTP 400 (Request Error). The server log has the following to say:
ERROR [geoserver.rest] - Could not determine format. Try setting the Content-type header.
org.geoserver.rest.RestletException
at org.geoserver.rest.AbstractResource.getFormatPostOrPut(AbstractResource.java:173)
at org.geoserver.rest.ReflectiveResource.handlePost(ReflectiveResource.java:116)
at org.restlet.Finder.handle(Finder.java:296)
at org.geoserver.rest.BeanDelegatingRestlet.handle(BeanDelegatingRestlet.java:37)
at org.restlet.Filter.doHandle(Filter.java:105)
at org.restlet.Filter.handle(Filter.java:134)
at org.restlet.Router.handle(Router.java:444)
at org.geoserver.rest.RESTDispatcher$1.handle(RESTDispatcher.java:204)
at com.noelios.restlet.ext.servlet.ServletConverter.service(ServletConverter.java:129)
at org.geoserver.rest.RESTDispatcher.handleRequestInternal(RESTDispatcher.java:86)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
[...]
It doesn't help that the documentation for Inetc does not indicate that /header
is an available option for inetc::post
nor inetc::put
. However, I've confirmed that I can use /header
to set the Content-type for inetc::post
requests to create workspaces and styles in GeoServer. There is something different about inetc::put
that either requires different syntax, or it just wasn't implemented correctly.
I haven't found a single example of someone performing an inetc::put
where they set the Content-type of the request. I have tried putting the /header
before, between, and after the URL
and local_file
. I can perform the PUT using the Firefox add-on "Poster", and using cURL. But it will not work with Inetc.
I am using the latest build of Inetc available off the link I shared above.
I just took a look at the source and when doing a PUT INetC will add "Content-Type: octet-stream" and "Content-Length: %size%" with HttpAddRequestHeaders(..., HTTP_ADDREQ_FLAG_ADD|HTTP_ADDREQ_FLAG_REPLACE)
after adding the headers specified by the caller.
You should ask the authors to add the "Content-Type" header before the other headers to fix this...