I'm getting a 404 error when attempting a PUT to a resource with the
If-None-Match request header set to '*'. I know a similar issue was
reported before and supposedly fixed, but I can reproduce this both
with 2.0.10 and 2.1rc1.

If I omit the If-None-Match header, the PUT works fine, returning 200.

I'm testing my app by executing these commands:
curl -v -X PUT -d 1 http://localhost:8182/a
curl -v -X PUT -d 2 --header 'If-None-Match: *' http://localhost:8182/b

which produces:

Starting the internal [HTTP/1.1] server on port 8182
Updating a to 1
2011-11-29      20:04:07        127.0.0.1       -       -       8182    PUT     
/a      -       200     0       1       102     http://localhost:8182   
curl/7.23.1
(x86_64-apple-darwin10.8.0) libcurl/7.23.1 OpenSSL/1.0.0e zlib/1.2.5
libidn/1.22     -
2011-11-29      20:04:18        127.0.0.1       -       -       8182    PUT     
/b      -       404     439     1       3       http://localhost:8182   
curl/7.23.1
(x86_64-apple-darwin10.8.0) libcurl/7.23.1 OpenSSL/1.0.0e zlib/1.2.5
libidn/1.22     -

I'm not sure if attachments will work, so I have put the full source
code for TestCaseApp.java below:


import java.util.HashMap;

import org.restlet.Application;
import org.restlet.Component;
import org.restlet.Restlet;
import org.restlet.data.Protocol;
import org.restlet.resource.Get;
import org.restlet.resource.Put;
import org.restlet.resource.ServerResource;
import org.restlet.routing.Router;


public class TestCaseApp extends Component implements Runnable {

        private static HashMap<String,String> entries;
        static {
                entries = new HashMap<String,String>();
                entries.put("foo", "bar");
        }

        public static void main(String[] args) {
                TestCaseApp instance = new TestCaseApp();
                instance.run();
        }

        public void run() {
                try {
                        getServers().add(Protocol.HTTP, 8182);
                        DataVaultRestlet restlet = new DataVaultRestlet();
                        getDefaultHost().attach(restlet);
                        start();
                } catch (Exception e) {
                        System.err.println("Unable to start server" + 
e.getMessage());
                }
        }

        public static class DataVaultRestlet extends Application {
                @Override
                public synchronized Restlet createInboundRoot() {
                        Router router = new Router(getContext());
                        router.attach("/{name}", EntryResource.class);
                        router.attach("/", RootResource.class);
                        return router;
                }
        }

        public static class RootResource extends ServerResource {
                @Override
                @Get
                public String toString() {
                        StringBuilder rep = new StringBuilder();
                        for (String name : entries.keySet())
                                rep.append(name);
                        return rep.toString();
                }
        }

        public static class EntryResource extends ServerResource {
                @Override
                @Get
                public String toString() {
                        String name = (String) 
getRequest().getAttributes().get("name");
                        return entries.get(name);
                }
                @Put
                public String update(String value) {
                        String name = (String) 
getRequest().getAttributes().get("name");
                        System.err.println("Updating "+name+" to "+value);
                        return entries.put(name, value);
                }
        }
}

------------------------------------------------------
http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2889177

Reply via email to