Skip to content

Crashes on POST with a slug containing a / #304

Closed

Description

@dmitrizagidulin

To reproduce (first make sure a Solid directory is public-appendable, so that you don't get a 403 Unauthorized):

curl -vk -XPOST https://localhost:8443/profile/ -H 'Slug: movies/'

< HTTP/1.1 409 Conflict

# And on the LDnode side:
ldnode:handlers POST -- On parent: /profile/ +0ms
  ldnode:handlers POST -- Will create at: /profile/movies/ +1ms
  ldnode:server Error page because of PUT not supported on containers, use POST instead +0ms
  ldnode:post File stored in /profile/movies/ +14ms
_http_outgoing.js:346
    throw new Error('Can\'t set headers after they are sent.');
    ^

Error: Can't set headers after they are sent.
    at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:346:11)
    at ServerResponse.header (/Users/dmitri/code/_Solid/ldnode/node_modules/express/lib/response.js:718:10)
    at /Users/dmitri/code/_Solid/ldnode/lib/handlers/post.js:92:13
    at /Users/dmitri/code/_Solid/ldnode/lib/ldp.js:348:7
    at LDP.put (/Users/dmitri/code/_Solid/ldnode/lib/ldp.js:360:12)
    at /Users/dmitri/code/_Solid/ldnode/lib/ldp.js:345:9
    at /Users/dmitri/code/_Solid/ldnode/lib/ldp.js:520:7
    at /Users/dmitri/code/_Solid/ldnode/node_modules/async/lib/async.js:789:30
    at /Users/dmitri/code/_Solid/ldnode/node_modules/async/lib/async.js:167:37
    at /Users/dmitri/code/_Solid/ldnode/lib/ldp.js:513:9

Incidentally, note the line ldnode:server Error page because of PUT not supported on containers, use POST instead +0ms -- that shouldn't be happening, since this is a POST.

This is probably happening because the line doesn't include the appropriate -H 'Link: <http://www.w3.org/ns/ldp#BasicContainer>; rel="type"' header (meaning, this is a plain resource).
Anyways, should probably be fixed :)

Activity

  1. nicola commented on Mar 31, 2016

    @nicola
    Contributor

    I think it must be because you have / in the slug, will check soon (sorry I did not read the title)

  2. nicola commented on Mar 31, 2016

    @nicola
    Contributor

    @deiu @dmitrizagidulin what should the default behavior be?

    I think:

    • drop the slash if it it in the beginning or at the end
    • in case the slash is in the middle return 406 bad request
  3. deiu commented on Mar 31, 2016

    @deiu

    Yes, always drop the slash. You should never have a slash in the slug, since the value of this header should be the name of the resource, not a path! I think doing something along the lines of .replace('/', '') should fix it.

  4. nicola commented on Mar 31, 2016

    @nicola
    Contributor

    or maybe replace it with a urlencoded string if it is in the middle

  5. dmitrizagidulin commented on Mar 31, 2016

    @dmitrizagidulin
    ContributorAuthor

    +1 to dropping the slash. (though I'm fine with bad request error too)

  6. nicola commented on Apr 6, 2016

    @nicola
    Contributor

    fixed in #311

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions