Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL redirection when www.fairdomhub.org is used in API create #105

Open
ablejec opened this issue Nov 20, 2019 · 0 comments
Open

URL redirection when www.fairdomhub.org is used in API create #105

ablejec opened this issue Nov 20, 2019 · 0 comments

Comments

@ablejec
Copy link

@ablejec ablejec commented Nov 20, 2019

When trying to create objects by API at FAIRDOMhub, I used a wrong address, namely
www.fairdomhub.org instead of fairdomhub.org (Thank you ALan for helping me to find this out :)

Instead of creating an object (e.g. a study as listed below) the response was a list of studies. It seems that www prefixed address is good for GET but not for POST/PUT.

When using the www prefixed address, API requests are redirected (HTTP/1.1 302 Found) to the correct one (no www), but the object is not created. Details of communication is listed below.

Since www prefix is ok for reading, it is confusing when the writing doesn't work - I suggest that API checks the correctness of the URL and returns an informative error (Wrong URL, omit www, or something like that) instead of returning a list of objects (with 200 OK).

The communication transcript of unsuccesful study creation is below:

-> POST /studies HTTP/1.1
-> Host: www.fairdomhub.org
-> Authorization: Basic YWJsZWplYzpBYmluay45OTEy
-> User-Agent: https://github.com/ablejec/pisar
-> Accept-Encoding: deflate, gzip
-> Accept: application/json
-> Content-Type: application/json
-> Content-Length: 780
->

{
"data": {
"type": "studies",
"attributes": {
"title": "/2019-11-18 12:53:44-Andrej created study",
"description": "",
"experimentalists": "",
"person_responsible_id": "808",
"other_creators": "",
"policy": {
"access": "download",
"permissions": [
{
"resource": {
"id": "161",
"type": "projects"
},
"access": "manage"
}
]
}
},
"relationships": {
"investigation": {
"data": {
"id": "342",
"type": "investigations"
}
},
"creators": {
"data": [
{
"id": "808",
"type": "people"
}
]
}
}
}
}

<- HTTP/1.1 302 Found
<- Date: Mon, 18 Nov 2019 11:53:47 GMT
<- Server: Apache/2.4.29 (Ubuntu)
<- Location: https://fairdomhub.org/studies
<- Content-Length: 299
<- Content-Type: text/html; charset=iso-8859-1
<-
-> GET /studies HTTP/1.1
-> Host: fairdomhub.org
-> Authorization: Basic YWJsZWplYzpBYmluay45OTEy
-> User-Agent: https://github.com/ablejec/pisar
-> Accept-Encoding: deflate, gzip
-> Cookie: _seek_session=c0f915c94294803c39b6b6276ec474b7
-> Accept: application/json
-> Content-Type: application/json
->
<- HTTP/1.1 200 OK
<- Date: Mon, 18 Nov 2019 11:53:47 GMT
<- Server: Apache/2.4.29 (Ubuntu)
<- Cache-Control: max-age=0, private, must-revalidate
<- Referrer-Policy: strict-origin-when-cross-origin
<- X-Permitted-Cross-Domain-Policies: none
<- X-XSS-Protection: 1; mode=block
<- X-Request-Id: 346f82f8-aca4-4653-8030-9017bae57489
<- X-Download-Options: noopen
<- X-Frame-Options: SAMEORIGIN
<- X-Runtime: 0.110233
<- X-Content-Type-Options: nosniff
<- X-Powered-By: Phusion Passenger 5.1.2
<- Set-Cookie: _seek_session=c0f915c94294803c39b6b6276ec474b7; path=/; expires=Mon, 18 Nov 2019 12:53:47 -0000; HttpOnly
<- ETag: W/"111c98e5c02b77ed4e028d5948423c9c"
<- Status: 200 OK
<- Transfer-Encoding: chunked
<- Content-Type: application/vnd.api+json; charset=utf-8
<-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.