Hi Alessandro,
I think this is because of curl --data/-d option. Here are some excerpts
-d/--data is the same as --data-ascii. To post data purely binary,
you should instead use the --data-binary option. To URL-encode
the value of a form field you may use --data-urlencode.
If you start the data with the letter @, the rest should
be a file name to read the data from, or - if you want curl to read
the
data from stdin. The contents of the file must already
be URL-encoded. Multiple files can also be specified. Posting data
from a
file named 'foobar' would thus be done with --data @foobar.
so note that calling
> % curl -i -X POST -H "Content-type: text/turtle" -d @turtle-comments.rdf
> http://localhost:8080//ontonet/session/s1
would require the "turtle-comments.rdf" file to contain URL encoded content!
I think using the "--data-urlencode" option should solve your problem
as the documentation states
Data is posted in a similar manner as --data-ascii does,
except that newlines are preserved and conversions are never done.
best
Rupert
On Fri, Jul 13, 2012 at 6:30 PM, Alessandro Adamou <[email protected]> wrote:
> Hi
>
> I've been going literally MAD over the last few days on a bizarre
> phenomenon:
>
> if I POST an ontology
>
> 1) in Turtle/N3/N-Triple format on an OntoNet Scope/Session/whatever,
>
> 2) I use the service that accepts the payload as
> application/x-www-form-urlencoded
>
> 3) and that ontology has inline comments (starting in '#'),
>
> then whatever follows that comment is truncated.
>
> Say I have the following code
>
> ==================
> @prefix : <http://stanbol.apache.org/ontologies/test/> .
> @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> @base <http://stanbol.apache.org/ontologies/test/turtle/sample/comments> .
>
> <http://stanbol.apache.org/ontologies/test/turtle/triples/sample/comments>
> rdf:type owl:Ontology .
>
> # Comment
>
> :SomeClazz rdf:type owl:Class .
>
> :SomeThing1 rdf:type :SomeClazz .
> ==================
>
> stored in the file turtle-comments.rdf
>
> then I do
>
> % curl -i -X PUT http://localhost:8080/ontonet/session/s1
>
> % curl -i -X POST -H "Content-type: text/turtle" -d @turtle-comments.rdf
> http://localhost:8080//ontonet/session/s1
>
> Then when I GET the new resource
>
> curl -i -H "Accept: application/rdf+xml"
> http://localhost:8080/ontonet/session/s1/http://stanbol.apache.org/ontologies/test/turtle/triples/sample/comments
>
> the last two triples are missing!
>
> Instead, if I force post binary data, as in
>
> % curl -i -X POST -H "Content-type: text/turtle" --data-binary
> @turtle-comments.rdf http://localhost:8080//ontonet/session/s1
>
> it seems to work.
>
> It also works if I POST using the multipart/form-data variant
>
> % curl -i -X POST -F "format=text/turtle" -F [email protected]
> http://localhost:8080/ontonet/session/s1
>
> and both variants do exactly the same thing: they create a
> GraphContentInputSource object out of a BufferedInputStream that wraps the
> InputStream they get:
>
> - for application/x-www-form-urlencoded it is a
> org.mortbay.jetty.HttpParser.Input
> - for multipart/form-data it is a FileInputStream
>
> Something seems to be going very wrong when the hash character is
> URLencoded, but apparently when it is used in namespaces it doesn't seem to
> be a problem.
>
> Not a big deal if I can just get away with it by using --data-binary, but
> it's taken me two days to find out.
>
> Does anybody know if this is normal?
>
> Best,
>
> Alessandro
>
> --
> M.Sc. Alessandro Adamou
>
> Alma Mater Studiorum - Università di Bologna
> Department of Computer Science
> Mura Anteo Zamboni 7, 40127 Bologna - Italy
>
> Semantic Technology Laboratory (STLab)
> Institute for Cognitive Science and Technology (ISTC)
> National Research Council (CNR)
> Via Nomentana 56, 00161 Rome - Italy
>
>
> "I will give you everything, just don't demand anything."
> (Ettore Petrolini, 1917)
>
> Not sent from my iSnobTechDevice
>
--
| Rupert Westenthaler [email protected]
| Bodenlehenstraße 11 ++43-699-11108907
| A-5500 Bischofshofen