-
Notifications
You must be signed in to change notification settings - Fork 225
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
Add cookie to check share link access #691
Conversation
cookie_header = g_strdup_printf ("Cookie: %s", cookie); | ||
headers = curl_slist_append (headers, cookie_header); | ||
g_free (cookie_header); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个代码的位置往下面移动一下吧,感觉中断了 token_header 的代码。
server/http-tx-mgr.c
Outdated
@@ -609,12 +610,17 @@ http_tx_manager_query_share_link_info (const char *token, const char *type) | |||
curl = conn->curl; | |||
headers = curl_slist_append (headers, "User-Agent: Seafile/"SEAFILE_CLIENT_VERSION" ("USER_AGENT_OS")"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
检查一下其他代码,这里的 User-Agent 应该改为 Seafile server 吧。
header := map[string][]string{ | ||
"Authorization": {"Token " + tokenString}, | ||
} | ||
if cookie != "" { | ||
header["Cookie"] = []string{cookie} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个请求没有设置 applicateion/json 的头部。可以在 HttpCommon 里面自动设置。HttpCommon 也需要增加请求超时。
server/http-tx-mgr.c
Outdated
@@ -365,7 +365,7 @@ http_post (Connection *conn, const char *url, const char *token, | |||
|
|||
curl = conn->curl; | |||
|
|||
headers = curl_slist_append (headers, "User-Agent: Seafile/"SEAFILE_CLIENT_VERSION" ("USER_AGENT_OS")"); | |||
headers = curl_slist_append (headers, "User-Agent: Seafile Server/"SEAFILE_CLIENT_VERSION" ("USER_AGENT_OS")"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
后面不用加 version 了,而且你这个也是客户端的版本。这些宏也删掉吧。
@@ -20,7 +19,10 @@ func GetAuthorizationToken(h http.Header) string { | |||
} | |||
|
|||
func HttpCommon(method, url string, header map[string][]string, reader io.Reader) (int, []byte, error) { | |||
req, err := http.NewRequestWithContext(HttpReqContext, method, url, reader) | |||
header["Content-Type"] = []string{"application/json"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里设置了这个头部,就不用再调用 HttpCommon 之前设置了。多余的代码删除吧。
"inline;filename=\"%s\"", filename); | ||
} | ||
snprintf(cont_filename, SEAF_PATH_MAX, | ||
"inline;filename*=utf-8''%s;filename=\"%s\"", esc_filename, filename); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个需要在 Chrome, Firefox 和 Safari 三个浏览器上测试。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个测过了
No description provided.