[NETCONF-8] OPTIONS HTTP method cannot return JSON response but 405 method Created: 06/Oct/14  Updated: 23/Sep/20  Resolved: 23/Sep/20

Status: Resolved
Project: netconf
Component/s: restconf-nb
Affects Version/s: None
Fix Version/s: Aluminium SR1

Type: Improvement
Reporter: RichardHill Assignee: RichardHill
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: 0 minutes
Time Spent: 3 hours
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Attachments: Text File OPTION-HTTP-response-in-XML.txt    

 Description   

Testing this I expected a HTTP "OPTIONS" request in both XML and JSON formats to return 200 and a payload describing the OPTIONS available. The XML test was successful, but the JSON test failed and threw a 405 HTTP ERROR.

###Test setup ###

install this http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/integration/distribution-karaf/0.2.0-SNAPSHOT/distribution-karaf-0.2.0-20141002.195140-199.zip.sha1

###Steps

Create a data resource

curl -v -X POST -d "<nodes xmlns=\"urn:opendaylight:inventory\"><node><id>id1</id></node></nodes>" localhost:8080/restconf/config/ --header "Content-Type:application/xml" --header "Accept:application/xml"

Verify it was present

curl -v -X GET 172.29.50.236:8080/re "Content-Type:application/xml" --header "Accept:application/xml"

Now I tried to check the OPTIONS, looks ok with XML

curl -v -X OPTIONS 172.29.50.236:8080/restconf/config/opendaylight-inventory:nodes/node/id1 "Content-Type:application/xml" --header "Accept:application/xml

This returns XML you can see it in the attachment.

curl -v -X OPTIONS 172.29.50.236:8080/restconf/config/opendaylight-inventory:nodes/node/id1 "Content-Type:application/xml" --header "Accept:application/json

returns $)% status and a HTML page with a tomcat error message

"The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers."



 Comments   
Comment by RichardHill [ 06/Oct/14 ]

Attachment OPTION-HTTP-response-in-XML.txt has been added with description: Response in XML fromat from OPTIONS HTTP method

Comment by Tony Tkacik [ 06/Oct/14 ]

This could be fixed in NormalizedNodeJSONBodyWriter and NormalizedNodeXmlBodyWriter
which as of now, should have access to URIInfo and from that they could learn if pretty-print is set.

Both StreamWriters (JSON and XML) should have property to enable indentation, or at
least it is possible to insert indenting writer in pipeline.

Comment by Jozef Gloncak [ 14/Oct/14 ]

Response to HTTP OPTIONS operation isn't implemented via @OPTIONS jax-rs annotation.

For this case according to JAX-RS specification http://download.oracle.com/otndocs/jcp/jaxrs-1.1-mrel-eval-oth-JSpec/ the following behavior is requested(quoting 3.3.5)

>>>>>
On receipt of an OPTIONS request an implementation MUST either:
1. Call a method annotated with a request method designator for OPTIONS or, if none present,
2. Generate an automatic response using the metadata provided by the JAX-RS annotations on the match-ing class and its methods.
<<<<<

Details about how second possibility is specified in jersey is described in https://jersey.java.net/documentation/latest/wadl.html#d0e11496.

As was specified in response for Accept: application/json
"The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers."

It seems that only application/xml format is supported by jersey implementation.

My conclusion is that testing scenario where you are awaiting JSON output for OPTIONS HTTP request isn't valid.

Comment by Robert Varga [ 13/Nov/15 ]

Move to NETCONF project

Comment by Iaroslav Kholiavko [ 23/Sep/20 ]

Could not reproduce onĀ Aluminium

Generated at Wed Feb 07 20:13:56 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.