{"action":"created","comment":{"url":"https://api.github.com/repos/cesanta/fossa/pulls/comments/22408714","id":22408714,"diff_hunk":"@@ -2484,6 +2484,227 @@ void ns_printf_http_chunk(struct ns_connection *nc, const char *fmt, ...) {\n   /* LCOV_EXCL_STOP */\n }\n \n+int ns_http_parse_header(struct ns_str *hdr, const char *var_name,\n+                         char *buf, size_t buf_size) {\n+  int ch = ' ', ch1 = ',', len = 0, n = strlen(var_name);\n+  const char *p, *end = hdr->p + hdr->len, *s = NULL;\n+\n+  if (buf != NULL && buf_size > 0) buf[0] = '\\0';\n+\n+  /* Find where variable starts */\n+  for (s = hdr->p; s != NULL && s + n < end; s++) {\n+    if ((s == hdr->p || s[-1] == ch || s[-1] == ch1) && s[n] == '=' &&\n+        !memcmp(s, var_name, n)) break;\n+  }\n+\n+  if (s != NULL && &s[n + 1] < end) {\n+    s += n + 1;\n+    if (*s == '\"' || *s == '\\'') {\n+      ch = ch1 = *s++;\n+    }\n+    p = s;\n+    while (p < end && p[0] != ch && p[0] != ch1 && len < (int) buf_size) {\n+      if (ch != ' ' && p[0] == '\\\\' && p[1] == ch) p++;\n+      buf[len++] = *p++;\n+    }\n+    if (len >= (int) buf_size || (ch != ' ' && *p != ch)) {\n+      len = 0;\n+    } else {\n+      if (len > 0 && s[len - 1] == ',') len--;\n+      if (len > 0 && s[len - 1] == ';') len--;\n+      buf[len] = '\\0';\n+    }\n+  }\n+\n+  return len;\n+}\n+\n+#ifndef NS_DISABLE_HTTP_DIGEST_AUTH\n+static FILE *open_auth_file(const char *path, int is_directory,\n+                            const struct ns_serve_http_opts *opts) {\n+  char buf[MAX_PATH_SIZE];\n+  const char *p;\n+  FILE *fp = NULL;\n+\n+  if (opts->global_auth_file != NULL) {\n+    fp = fopen(opts->global_auth_file, \"r\");\n+  } else if (is_directory && opts->per_directory_auth_file) {\n+    snprintf(buf, sizeof(buf), \"%s%c%s\", path, '/',","path":"fossa.c","position":60,"original_position":60,"commit_id":"9854a73b5539dc03997b575d0d3b6941322afa6a","original_commit_id":"9854a73b5539dc03997b575d0d3b6941322afa6a","user":{"login":"cpq","id":601816,"avatar_url":"https://avatars.githubusercontent.com/u/601816?v=3","gravatar_id":"","url":"https://api.github.com/users/cpq","html_url":"https://github.com/cpq","followers_url":"https://api.github.com/users/cpq/followers","following_url":"https://api.github.com/users/cpq/following{/other_user}","gists_url":"https://api.github.com/users/cpq/gists{/gist_id}","starred_url":"https://api.github.com/users/cpq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpq/subscriptions","organizations_url":"https://api.github.com/users/cpq/orgs","repos_url":"https://api.github.com/users/cpq/repos","events_url":"https://api.github.com/users/cpq/events{/privacy}","received_events_url":"https://api.github.com/users/cpq/received_events","type":"User","site_admin":false},"body":"Done","created_at":"2015-01-02T11:37:14Z","updated_at":"2015-01-02T11:37:14Z","html_url":"https://github.com/cesanta/fossa/pull/184#discussion_r22408714","pull_request_url":"https://api.github.com/repos/cesanta/fossa/pulls/184","_links":{"self":{"href":"https://api.github.com/repos/cesanta/fossa/pulls/comments/22408714"},"html":{"href":"https://github.com/cesanta/fossa/pull/184#discussion_r22408714"},"pull_request":{"href":"https://api.github.com/repos/cesanta/fossa/pulls/184"}}},"pull_request":{"url":"https://api.github.com/repos/cesanta/fossa/pulls/184","id":26514205,"html_url":"https://github.com/cesanta/fossa/pull/184","diff_url":"https://github.com/cesanta/fossa/pull/184.diff","patch_url":"https://github.com/cesanta/fossa/pull/184.patch","issue_url":"https://api.github.com/repos/cesanta/fossa/issues/184","number":184,"state":"open","locked":false,"title":"Add md5 (for HTTP Digest Auth)","user":{"login":"cpq","id":601816,"avatar_url":"https://avatars.githubusercontent.com/u/601816?v=3","gravatar_id":"","url":"https://api.github.com/users/cpq","html_url":"https://github.com/cpq","followers_url":"https://api.github.com/users/cpq/followers","following_url":"https://api.github.com/users/cpq/following{/other_user}","gists_url":"https://api.github.com/users/cpq/gists{/gist_id}","starred_url":"https://api.github.com/users/cpq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cpq/subscriptions","organizations_url":"https://api.github.com/users/cpq/orgs","repos_url":"https://api.github.com/users/cpq/repos","events_url":"https://api.github.com/users/cpq/events{/privacy}","received_events_url":"https://api.github.com/users/cpq/received_events","type":"User","site_admin":false},"body":"","created_at":"2014-12-23T14:57:32Z","updated_at":"2015-01-02T11:37:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3af64895da9e7d09555a31f20d81e46c3fee1ecd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cesanta/fossa/pulls/184/commits","review_comments_url":"https://api.github.com/repos/cesanta/fossa/pulls/184/comments","review_comment_url":"https://api.github.com/repos/cesanta/fossa/pulls/comments/{number}","comments_url":"https://api.github.com/repos/cesanta/fossa/issues/184/comments","statuses_url":"https://api.github.com/repos/cesanta/fossa/statuses/9854a73b5539dc03997b575d0d3b6941322afa6a","head":{"label":"cesanta:md5","ref":"md5","sha":"9854a73b5539dc03997b575d0d3b6941322afa6a","user":{"login":"cesanta","id":5111322,"avatar_url":"https://avatars.githubusercontent.com/u/5111322?v=3","gravatar_id":"","url":"https://api.github.com/users/cesanta","html_url":"https://github.com/cesanta","followers_url":"https://api.github.com/users/cesanta/followers","following_url":"https://api.github.com/users/cesanta/following{/other_user}","gists_url":"https://api.github.com/users/cesanta/gists{/gist_id}","starred_url":"https://api.github.com/users/cesanta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cesanta/subscriptions","organizations_url":"https://api.github.com/users/cesanta/orgs","repos_url":"https://api.github.com/users/cesanta/repos","events_url":"https://api.github.com/users/cesanta/events{/privacy}","received_events_url":"https://api.github.com/users/cesanta/received_events","type":"Organization","site_admin":false},"repo":{"id":16724014,"name":"fossa","full_name":"cesanta/fossa","owner":{"login":"cesanta","id":5111322,"avatar_url":"https://avatars.githubusercontent.com/u/5111322?v=3","gravatar_id":"","url":"https://api.github.com/users/cesanta","html_url":"https://github.com/cesanta","followers_url":"https://api.github.com/users/cesanta/followers","following_url":"https://api.github.com/users/cesanta/following{/other_user}","gists_url":"https://api.github.com/users/cesanta/gists{/gist_id}","starred_url":"https://api.github.com/users/cesanta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cesanta/subscriptions","organizations_url":"https://api.github.com/users/cesanta/orgs","repos_url":"https://api.github.com/users/cesanta/repos","events_url":"https://api.github.com/users/cesanta/events{/privacy}","received_events_url":"https://api.github.com/users/cesanta/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cesanta/fossa","description":"Async non-blocking multi-protocol networking library for C/C++","fork":false,"url":"https://api.github.com/repos/cesanta/fossa","forks_url":"https://api.github.com/repos/cesanta/fossa/forks","keys_url":"https://api.github.com/repos/cesanta/fossa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cesanta/fossa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cesanta/fossa/teams","hooks_url":"https://api.github.com/repos/cesanta/fossa/hooks","issue_events_url":"https://api.github.com/repos/cesanta/fossa/issues/events{/number}","events_url":"https://api.github.com/repos/cesanta/fossa/events","assignees_url":"https://api.github.com/repos/cesanta/fossa/assignees{/user}","branches_url":"https://api.github.com/repos/cesanta/fossa/branches{/branch}","tags_url":"https://api.github.com/repos/cesanta/fossa/tags","blobs_url":"https://api.github.com/repos/cesanta/fossa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cesanta/fossa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cesanta/fossa/git/refs{/sha}","trees_url":"https://api.github.com/repos/cesanta/fossa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cesanta/fossa/statuses/{sha}","languages_url":"https://api.github.com/repos/cesanta/fossa/languages","stargazers_url":"https://api.github.com/repos/cesanta/fossa/stargazers","contributors_url":"https://api.github.com/repos/cesanta/fossa/contributors","subscribers_url":"https://api.github.com/repos/cesanta/fossa/subscribers","subscription_url":"https://api.github.com/repos/cesanta/fossa/subscription","commits_url":"https://api.github.com/repos/cesanta/fossa/commits{/sha}","git_commits_url":"https://api.github.com/repos/cesanta/fossa/git/commits{/sha}","comments_url":"https://api.github.com/repos/cesanta/fossa/comments{/number}","issue_comment_url":"https://api.github.com/repos/cesanta/fossa/issues/comments/{number}","contents_url":"https://api.github.com/repos/cesanta/fossa/contents/{+path}","compare_url":"https://api.github.com/repos/cesanta/fossa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cesanta/fossa/merges","archive_url":"https://api.github.com/repos/cesanta/fossa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cesanta/fossa/downloads","issues_url":"https://api.github.com/repos/cesanta/fossa/issues{/number}","pulls_url":"https://api.github.com/repos/cesanta/fossa/pulls{/number}","milestones_url":"https://api.github.com/repos/cesanta/fossa/milestones{/number}","notifications_url":"https://api.github.com/repos/cesanta/fossa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cesanta/fossa/labels{/name}","releases_url":"https://api.github.com/repos/cesanta/fossa/releases{/id}","created_at":"2014-02-11T08:21:42Z","updated_at":"2014-12-29T13:13:25Z","pushed_at":"2014-12-30T03:50:08Z","git_url":"git://github.com/cesanta/fossa.git","ssh_url":"git@github.com:cesanta/fossa.git","clone_url":"https://github.com/cesanta/fossa.git","svn_url":"https://github.com/cesanta/fossa","homepage":"http://cesanta.com","size":8273,"stargazers_count":78,"watchers_count":78,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":29,"mirror_url":null,"open_issues_count":15,"forks":29,"open_issues":15,"watchers":78,"default_branch":"master"}},"base":{"label":"cesanta:master","ref":"master","sha":"942d51debca9031b958944f5e909b24d5240cad2","user":{"login":"cesanta","id":5111322,"avatar_url":"https://avatars.githubusercontent.com/u/5111322?v=3","gravatar_id":"","url":"https://api.github.com/users/cesanta","html_url":"https://github.com/cesanta","followers_url":"https://api.github.com/users/cesanta/followers","following_url":"https://api.github.com/users/cesanta/following{/other_user}","gists_url":"https://api.github.com/users/cesanta/gists{/gist_id}","starred_url":"https://api.github.com/users/cesanta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cesanta/subscriptions","organizations_url":"https://api.github.com/users/cesanta/orgs","repos_url":"https://api.github.com/users/cesanta/repos","events_url":"https://api.github.com/users/cesanta/events{/privacy}","received_events_url":"https://api.github.com/users/cesanta/received_events","type":"Organization","site_admin":false},"repo":{"id":16724014,"name":"fossa","full_name":"cesanta/fossa","owner":{"login":"cesanta","id":5111322,"avatar_url":"https://avatars.githubusercontent.com/u/5111322?v=3","gravatar_id":"","url":"https://api.github.com/users/cesanta","html_url":"https://github.com/cesanta","followers_url":"https://api.github.com/users/cesanta/followers","following_url":"https://api.github.com/users/cesanta/following{/other_user}","gists_url":"https://api.github.com/users/cesanta/gists{/gist_id}","starred_url":"https://api.github.com/users/cesanta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cesanta/subscriptions","organizations_url":"https://api.github.com/users/cesanta/orgs","repos_url":"https://api.github.com/users/cesanta/repos","events_url":"https://api.github.com/users/cesanta/events{/privacy}","received_events_url":"https://api.github.com/users/cesanta/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cesanta/fossa","description":"Async non-blocking multi-protocol networking library for C/C++","fork":false,"url":"https://api.github.com/repos/cesanta/fossa","forks_url":"https://api.github.com/repos/cesanta/fossa/forks","keys_url":"https://api.github.com/repos/cesanta/fossa/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cesanta/fossa/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cesanta/fossa/teams","hooks_url":"https://api.github.com/repos/cesanta/fossa/hooks","issue_events_url":"https://api.github.com/repos/cesanta/fossa/issues/events{/number}","events_url":"https://api.github.com/repos/cesanta/fossa/events","assignees_url":"https://api.github.com/repos/cesanta/fossa/assignees{/user}","branches_url":"https://api.github.com/repos/cesanta/fossa/branches{/branch}","tags_url":"https://api.github.com/repos/cesanta/fossa/tags","blobs_url":"https://api.github.com/repos/cesanta/fossa/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cesanta/fossa/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cesanta/fossa/git/refs{/sha}","trees_url":"https://api.github.com/repos/cesanta/fossa/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cesanta/fossa/statuses/{sha}","languages_url":"https://api.github.com/repos/cesanta/fossa/languages","stargazers_url":"https://api.github.com/repos/cesanta/fossa/stargazers","contributors_url":"https://api.github.com/repos/cesanta/fossa/contributors","subscribers_url":"https://api.github.com/repos/cesanta/fossa/subscribers","subscription_url":"https://api.github.com/repos/cesanta/fossa/subscription","commits_url":"https://api.github.com/repos/cesanta/fossa/commits{/sha}","git_commits_url":"https://api.github.com/repos/cesanta/fossa/git/commits{/sha}","comments_url":"https://api.github.com/repos/cesanta/fossa/comments{/number}","issue_comment_url":"https://api.github.com/repos/cesanta/fossa/issues/comments/{number}","contents_url":"https://api.github.com/repos/cesanta/fossa/contents/{+path}","compare_url":"https://api.github.com/repos/cesanta/fossa/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cesanta/fossa/merges","archive_url":"https://api.github.com/repos/cesanta/fossa/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cesanta/fossa/downloads","issues_url":"https://api.github.com/repos/cesanta/fossa/issues{/number}","pulls_url":"https://api.github.com/repos/cesanta/fossa/pulls{/number}","milestones_url":"https://api.github.com/repos/cesanta/fossa/milestones{/number}","notifications_url":"https://api.github.com/repos/cesanta/fossa/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cesanta/fossa/labels{/name}","releases_url":"https://api.github.com/repos/cesanta/fossa/releases{/id}","created_at":"2014-02-11T08:21:42Z","updated_at":"2014-12-29T13:13:25Z","pushed_at":"2014-12-30T03:50:08Z","git_url":"git://github.com/cesanta/fossa.git","ssh_url":"git@github.com:cesanta/fossa.git","clone_url":"https://github.com/cesanta/fossa.git","svn_url":"https://github.com/cesanta/fossa","homepage":"http://cesanta.com","size":8273,"stargazers_count":78,"watchers_count":78,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":29,"mirror_url":null,"open_issues_count":15,"forks":29,"open_issues":15,"watchers":78,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cesanta/fossa/pulls/184"},"html":{"href":"https://github.com/cesanta/fossa/pull/184"},"issue":{"href":"https://api.github.com/repos/cesanta/fossa/issues/184"},"comments":{"href":"https://api.github.com/repos/cesanta/fossa/issues/184/comments"},"review_comments":{"href":"https://api.github.com/repos/cesanta/fossa/pulls/184/comments"},"review_comment":{"href":"https://api.github.com/repos/cesanta/fossa/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/cesanta/fossa/pulls/184/commits"},"statuses":{"href":"https://api.github.com/repos/cesanta/fossa/statuses/9854a73b5539dc03997b575d0d3b6941322afa6a"}}}}