[NETCONF-676] The "Location" returned in response should be right as description in rfc8040 when create resource. Created: 26/Apr/20  Updated: 03/Aug/20  Due: 26/Apr/20  Resolved: 03/Aug/20

Status: Resolved
Project: netconf
Component/s: restconf-nb
Affects Version/s: None
Fix Version/s: Aluminium, Magnesium SR2, Sodium SR4

Type: Bug Priority: Medium
Reporter: wang senxiao Assignee: wang senxiao
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by NETCONF-659 location not returned in header when ... Resolved
Priority: Normal

 Description   

As description in rfc8040 chapter 4.4.1:

   If the POST method succeeds, a "201 Created" status-line is returned
and there is no response message-body. A "Location" header field
identifying the child resource that was created MUST be present in
the response in this case.

I check feature rfc8040, it returned "Locaiton", but not correct.

For example, I tested with this yang:

module tapi-common

{     .......... }

module tapi-connectivity {

    ..........

    augment "/tapi-common:context" {
       ext:augment-identifier "ext-connectivity-context";
       container connectivity-context {
           list connectivity-service

         

{   key 'uuid';                  uses connectivity-service;              }

       }

   }

}

When I use postman to create resource "connectivity-service", as rfc8040 example in chapter  B.2.1 described, the "Location" in response shoulde be this, bring it uuid:

    Location →http://127.0.0.1:8181/rests/data/tapi-common:context/tapi-connectivity:connectivity-context/tapi-connectivity:connectivity-service=8238c723-c4b9-3ba1-a95c-7a46a03ef125

But actually returns:

    Location →http://127.0.0.1:8181/rests/data/tapi-common:context/tapi-connectivity:connectivity-context

Besides, the "Content-Type" also should be returned in response, it is the same as the "Content-Type" in the request.



 Comments   
Comment by Jamo Luhrsen [ 13/Jul/20 ]

Hi wsx25289, I am not sure if this is working as expected or not. There are a few things I noticed.

1. when we do a GET on a subscription URI (bierman works) we are not getting a header
response with the Location when it's done with rfc8040

2. Above you seem to indicate that the original bug was here so that we also get the Location returned in a 201 response
header after a POST to create the subscription. That's not happening for beirman or rfc8040. should it be?

Comment by wang senxiao [ 14/Jul/20 ]

The rfc8040 says "If the POST method succeeds, a "201 Created" status-line is returned and there is no response message-body. A "Location" header field identifying the child resource that was created MUST be present in the response in this case.". But I didn't see the description about location in GET.

Comment by Jamo Luhrsen [ 14/Jul/20 ]

correct me if I'm wrong, but I think this bug is still there. We don't see the Location returned in the POST to create, OR in the GET for rfc8040. It is
there for the beirman02 GET. This is currently breaking our new rfc8040 CSIT.

Here are the headers for each case:


beirman02 POST:

{'Set-Cookie': 'JSESSIONID=node0vl799fp3vr0nz05v66cwslv67.node0;Path=/, rememberMe=deleteMe; Path=/; Max-Age=0; Expires=Wed, 18-Mar-2020 21:42:19 GMT', 'Content-Length': '207', 'Expires': 'Thu, 01 Jan 1970 00:00:00 GMT', 'Content-Type': 'application/xml'}


beirman02 GET:

{'Content-Length': '173', 'Content-Type': 'application/xml', 'Location': 'ws://10.30.170.125:8185/data-change-event-subscription/opendaylight-inventory:nodes/datastore=CONFIGURATION/scope=BASE'}


rfc8040 POST:

{'Content-Type': 'application/xml', 'Content-Length': '207'}


rfc8040 GET:

{'Content-Type': 'application/xml', 'Content-Length': '179'}
Comment by Jamo Luhrsen [ 16/Jul/20 ]

I think this patch from vladyslav.marchenko might have helped some. At least CSIT
for rfc8040 is working now which means the GET is returning the Location in the header.

Does anyone know if it's a requirement or not that the POST should return the Location in a response header or not? You can see above
for the output of the POST response headers. it hasn't changed.

Comment by Jamo Luhrsen [ 29/Jul/20 ]

vladyslav.marchenko, so you know anything here? I notice that magnesium is still
failing , but this patch didn't make it to magnesium and may not even apply.

Comment by Vladyslav Marchenko [ 30/Jul/20 ]

I actually don't know if it's a requirement or not. Fixes about location in header in my patch was for restconf-nb-rfc8040. And I did the same as was done in restconf-nb-bierman02.
You can see it here:
https://git.opendaylight.org/gerrit/c/netconf/+/90371/21..24/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/NormalizedNodeXmlBodyWriter.java
https://git.opendaylight.org/gerrit/c/netconf/+/90371/21..24/restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/NormalizedNodeJsonBodyWriter.java

And that was the reason why CSIT failed at the beginning for my patch

Comment by Jamo Luhrsen [ 01/Aug/20 ]

Thanks for the help vladyslav.marchenko. Here is a patch to fix Mg:
https://git.opendaylight.org/gerrit/c/netconf/+/91805

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