zadean / xqerl

Erlang XQuery 3.1 Processor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

restXQ

grantmacken opened this issue · comments

restXQ implementation

I have opened this issue to monitor of the restXQ implementation status for xqerl.

current status re. HTTP methods

  • GET
    e.g. http://example.com
  • GET with query parameters
    e.g. curl http://example.com/?h=entry&content=Burn+Out
  • HEAD
    e.g curl --head http://example.com
  • OPTIONS
    e.g curl -X OPTIONS http://example.com
  • POST HTML form posting with
    Content-Type application/x-www-form-urlencoded
    curl --data-urlencode "name=xqerl app" http://www.example.com
  • POST multipart form file upload with
    Content-Type multipart/form-data
    e.g.curl --form upload=@localfilename http://www.example.com
  • POST base64 encoded application data with
    Content-Type: application/json or Content-Type: application/xml
 curl -H "Content-Type: application/json" \\
 -d  '{"h":"entry","content":"giday"}' \\
http://www.example.com/micropub

should return 201 status + location header

  • PUT send base64 application data with
    'Content-Type: application/json' or 'Content-Type: application/xml'
curl -X PUT \\
 -H "Content-Type: application/json" \\
 -d  '{"h":"entry","content":"giday"}' \\
http://www.example.com/micropub/id
  • PUT upload a file
    Content-Type: application/json or Content-Type: application/xml
curl --upload-file path/to/file
 -H "Content-Type: application/xml" \\
http://www.example.com/data/id
  • DELETE
    Content-Type: application/json or Content-Type: application/xml
    e.g. curl -X DELETE http://www.example.com/micropub/id

@zadean
re. RESTXQ fixup and test suite #21

The OPTIONS HTTP method is not yet handled correctly,
and the options_1 test case run, does not uncover the error.

The restXQ endpoint /test/options/xml
should 'allow' only 'GET,HEAD' response.
yet the cowboy response is

 < allow: DELETE, GET, HEAD, OPTIONS, POST

The following is the call and output from curl

* Connected to localhost (127.0.0.1) port 8081 (#0)
> OPTIONS /test/options/xml HTTP/1.1
> Host: localhost:8081
> User-Agent: curl/7.66.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< allow: DELETE, GET, HEAD, OPTIONS, POST
< content-length: 0
< date: Sun, 10 Nov 2019 18:06:57 GMT
< server: Cowboy

okay, I think #24 fixed it. It now handles OPTIONS calls, instead of deferring to the default.