{"action":"created","comment":{"url":"https://api.github.com/repos/google/google-api-nodejs-client/pulls/comments/24969428","id":24969428,"diff_hunk":"@@ -0,0 +1,65 @@\n+'use strict';\n+\n+var http_parser = require('http-string-parser');\n+\n+/**\n+ * BatchParser constructor.\n+ * @constructor\n+ * @param {object} transporter Transporter to use to send request\n+ */\n+function BatchTransporter(transporter) {\n+  this.transporter = transporter;\n+}\n+\n+/**\n+ * Makes a request with given options and invokes callback.\n+ * @param {object} opts Options.\n+ * @param {Function=} opt_callback Optional callback.\n+ * @return {Request} Request object\n+ */\n+BatchTransporter.prototype.request = function(opts, opt_callback) {\n+  return this.transporter.request(opts, this.wrapCallback_(opt_callback));\n+};\n+\n+/**\n+ * Wraps the response callback.\n+ * @param {Function=} opt_callback Optional callback.\n+ * @return {Function} Wrapped callback function.\n+ * @private\n+ */\n+BatchTransporter.prototype.wrapCallback_ = function(opt_callback) {\n+  return function(err, body, res) {\n+\n+    if (err || !body) {\n+      return opt_callback && opt_callback(err, body, res);\n+    }\n+\n+    if (res.headers['content-type'].indexOf('multipart/mixed') < 0) {\n+      return opt_callback && opt_callback(new Error('Unexpected response type.'));\n+    }\n+\n+    var boundary_regex = new RegExp('boundary=(.*)$', 'm');","path":"lib/batchtransporter.js","position":41,"original_position":41,"commit_id":"449a3bc1e23c2ede18cafa4a150adfafdd61e8f9","original_commit_id":"449a3bc1e23c2ede18cafa4a150adfafdd61e8f9","user":{"login":"ryanseys","id":163873,"avatar_url":"https://avatars.githubusercontent.com/u/163873?v=3","gravatar_id":"","url":"https://api.github.com/users/ryanseys","html_url":"https://github.com/ryanseys","followers_url":"https://api.github.com/users/ryanseys/followers","following_url":"https://api.github.com/users/ryanseys/following{/other_user}","gists_url":"https://api.github.com/users/ryanseys/gists{/gist_id}","starred_url":"https://api.github.com/users/ryanseys/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ryanseys/subscriptions","organizations_url":"https://api.github.com/users/ryanseys/orgs","repos_url":"https://api.github.com/users/ryanseys/repos","events_url":"https://api.github.com/users/ryanseys/events{/privacy}","received_events_url":"https://api.github.com/users/ryanseys/received_events","type":"User","site_admin":false},"body":"Some comments here would be great","created_at":"2015-02-19T07:09:53Z","updated_at":"2015-02-19T07:09:53Z","html_url":"https://github.com/google/google-api-nodejs-client/pull/371#discussion_r24969428","pull_request_url":"https://api.github.com/repos/google/google-api-nodejs-client/pulls/371","_links":{"self":{"href":"https://api.github.com/repos/google/google-api-nodejs-client/pulls/comments/24969428"},"html":{"href":"https://github.com/google/google-api-nodejs-client/pull/371#discussion_r24969428"},"pull_request":{"href":"https://api.github.com/repos/google/google-api-nodejs-client/pulls/371"}}},"pull_request":{"url":"https://api.github.com/repos/google/google-api-nodejs-client/pulls/371","id":29587295,"html_url":"https://github.com/google/google-api-nodejs-client/pull/371","diff_url":"https://github.com/google/google-api-nodejs-client/pull/371.diff","patch_url":"https://github.com/google/google-api-nodejs-client/pull/371.patch","issue_url":"https://api.github.com/repos/google/google-api-nodejs-client/issues/371","number":371,"state":"open","locked":false,"title":"Batch Requests","user":{"login":"ahageali","id":6454353,"avatar_url":"https://avatars.githubusercontent.com/u/6454353?v=3","gravatar_id":"","url":"https://api.github.com/users/ahageali","html_url":"https://github.com/ahageali","followers_url":"https://api.github.com/users/ahageali/followers","following_url":"https://api.github.com/users/ahageali/following{/other_user}","gists_url":"https://api.github.com/users/ahageali/gists{/gist_id}","starred_url":"https://api.github.com/users/ahageali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahageali/subscriptions","organizations_url":"https://api.github.com/users/ahageali/orgs","repos_url":"https://api.github.com/users/ahageali/repos","events_url":"https://api.github.com/users/ahageali/events{/privacy}","received_events_url":"https://api.github.com/users/ahageali/received_events","type":"User","site_admin":false},"body":"While experimental, I have tested this through the use of urlshortener apis and drive apis and this does appear to work for normal GET and POST requests. I have also added some documentation to provide a simple way to call the batch api. As a result however, the api requests no longer actually make their requests when they are called without a callback. \r\n\r\nI have also *tried* to keep as similar a style as possible to all the pre-existing code so I apologize if I made any horrendous mistakes. Let me know if you want any changes!","created_at":"2015-02-19T04:58:26Z","updated_at":"2015-02-19T07:09:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2f0f3560cfa834894d1a7e8c8540a56a87f93f01","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/google/google-api-nodejs-client/pulls/371/commits","review_comments_url":"https://api.github.com/repos/google/google-api-nodejs-client/pulls/371/comments","review_comment_url":"https://api.github.com/repos/google/google-api-nodejs-client/pulls/comments/{number}","comments_url":"https://api.github.com/repos/google/google-api-nodejs-client/issues/371/comments","statuses_url":"https://api.github.com/repos/google/google-api-nodejs-client/statuses/449a3bc1e23c2ede18cafa4a150adfafdd61e8f9","head":{"label":"ahageali:batchrequests","ref":"batchrequests","sha":"449a3bc1e23c2ede18cafa4a150adfafdd61e8f9","user":{"login":"ahageali","id":6454353,"avatar_url":"https://avatars.githubusercontent.com/u/6454353?v=3","gravatar_id":"","url":"https://api.github.com/users/ahageali","html_url":"https://github.com/ahageali","followers_url":"https://api.github.com/users/ahageali/followers","following_url":"https://api.github.com/users/ahageali/following{/other_user}","gists_url":"https://api.github.com/users/ahageali/gists{/gist_id}","starred_url":"https://api.github.com/users/ahageali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahageali/subscriptions","organizations_url":"https://api.github.com/users/ahageali/orgs","repos_url":"https://api.github.com/users/ahageali/repos","events_url":"https://api.github.com/users/ahageali/events{/privacy}","received_events_url":"https://api.github.com/users/ahageali/received_events","type":"User","site_admin":false},"repo":{"id":30940198,"name":"google-api-nodejs-client","full_name":"ahageali/google-api-nodejs-client","owner":{"login":"ahageali","id":6454353,"avatar_url":"https://avatars.githubusercontent.com/u/6454353?v=3","gravatar_id":"","url":"https://api.github.com/users/ahageali","html_url":"https://github.com/ahageali","followers_url":"https://api.github.com/users/ahageali/followers","following_url":"https://api.github.com/users/ahageali/following{/other_user}","gists_url":"https://api.github.com/users/ahageali/gists{/gist_id}","starred_url":"https://api.github.com/users/ahageali/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahageali/subscriptions","organizations_url":"https://api.github.com/users/ahageali/orgs","repos_url":"https://api.github.com/users/ahageali/repos","events_url":"https://api.github.com/users/ahageali/events{/privacy}","received_events_url":"https://api.github.com/users/ahageali/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ahageali/google-api-nodejs-client","description":"Google's officially supported Node.js client library for accessing Google APIs, it comes with OAuth 2.0 support.","fork":true,"url":"https://api.github.com/repos/ahageali/google-api-nodejs-client","forks_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/forks","keys_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/teams","hooks_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/hooks","issue_events_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/issues/events{/number}","events_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/events","assignees_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/assignees{/user}","branches_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/branches{/branch}","tags_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/tags","blobs_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/statuses/{sha}","languages_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/languages","stargazers_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/stargazers","contributors_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/contributors","subscribers_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/subscribers","subscription_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/subscription","commits_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/issues/comments/{number}","contents_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/contents/{+path}","compare_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/merges","archive_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/downloads","issues_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/issues{/number}","pulls_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/pulls{/number}","milestones_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/milestones{/number}","notifications_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/labels{/name}","releases_url":"https://api.github.com/repos/ahageali/google-api-nodejs-client/releases{/id}","created_at":"2015-02-17T22:03:31Z","updated_at":"2015-02-17T22:03:32Z","pushed_at":"2015-02-19T05:07:55Z","git_url":"git://github.com/ahageali/google-api-nodejs-client.git","ssh_url":"git@github.com:ahageali/google-api-nodejs-client.git","clone_url":"https://github.com/ahageali/google-api-nodejs-client.git","svn_url":"https://github.com/ahageali/google-api-nodejs-client","homepage":"","size":3218,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"google:master","ref":"master","sha":"88f12298fcc0a29e10f4df3d17333881be6f50b4","user":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"repo":{"id":8608480,"name":"google-api-nodejs-client","full_name":"google/google-api-nodejs-client","owner":{"login":"google","id":1342004,"avatar_url":"https://avatars.githubusercontent.com/u/1342004?v=3","gravatar_id":"","url":"https://api.github.com/users/google","html_url":"https://github.com/google","followers_url":"https://api.github.com/users/google/followers","following_url":"https://api.github.com/users/google/following{/other_user}","gists_url":"https://api.github.com/users/google/gists{/gist_id}","starred_url":"https://api.github.com/users/google/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/google/subscriptions","organizations_url":"https://api.github.com/users/google/orgs","repos_url":"https://api.github.com/users/google/repos","events_url":"https://api.github.com/users/google/events{/privacy}","received_events_url":"https://api.github.com/users/google/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/google/google-api-nodejs-client","description":"Google's officially supported Node.js client library for accessing Google APIs, it comes with OAuth 2.0 support.","fork":false,"url":"https://api.github.com/repos/google/google-api-nodejs-client","forks_url":"https://api.github.com/repos/google/google-api-nodejs-client/forks","keys_url":"https://api.github.com/repos/google/google-api-nodejs-client/keys{/key_id}","collaborators_url":"https://api.github.com/repos/google/google-api-nodejs-client/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/google/google-api-nodejs-client/teams","hooks_url":"https://api.github.com/repos/google/google-api-nodejs-client/hooks","issue_events_url":"https://api.github.com/repos/google/google-api-nodejs-client/issues/events{/number}","events_url":"https://api.github.com/repos/google/google-api-nodejs-client/events","assignees_url":"https://api.github.com/repos/google/google-api-nodejs-client/assignees{/user}","branches_url":"https://api.github.com/repos/google/google-api-nodejs-client/branches{/branch}","tags_url":"https://api.github.com/repos/google/google-api-nodejs-client/tags","blobs_url":"https://api.github.com/repos/google/google-api-nodejs-client/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/google/google-api-nodejs-client/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/google/google-api-nodejs-client/git/refs{/sha}","trees_url":"https://api.github.com/repos/google/google-api-nodejs-client/git/trees{/sha}","statuses_url":"https://api.github.com/repos/google/google-api-nodejs-client/statuses/{sha}","languages_url":"https://api.github.com/repos/google/google-api-nodejs-client/languages","stargazers_url":"https://api.github.com/repos/google/google-api-nodejs-client/stargazers","contributors_url":"https://api.github.com/repos/google/google-api-nodejs-client/contributors","subscribers_url":"https://api.github.com/repos/google/google-api-nodejs-client/subscribers","subscription_url":"https://api.github.com/repos/google/google-api-nodejs-client/subscription","commits_url":"https://api.github.com/repos/google/google-api-nodejs-client/commits{/sha}","git_commits_url":"https://api.github.com/repos/google/google-api-nodejs-client/git/commits{/sha}","comments_url":"https://api.github.com/repos/google/google-api-nodejs-client/comments{/number}","issue_comment_url":"https://api.github.com/repos/google/google-api-nodejs-client/issues/comments/{number}","contents_url":"https://api.github.com/repos/google/google-api-nodejs-client/contents/{+path}","compare_url":"https://api.github.com/repos/google/google-api-nodejs-client/compare/{base}...{head}","merges_url":"https://api.github.com/repos/google/google-api-nodejs-client/merges","archive_url":"https://api.github.com/repos/google/google-api-nodejs-client/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/google/google-api-nodejs-client/downloads","issues_url":"https://api.github.com/repos/google/google-api-nodejs-client/issues{/number}","pulls_url":"https://api.github.com/repos/google/google-api-nodejs-client/pulls{/number}","milestones_url":"https://api.github.com/repos/google/google-api-nodejs-client/milestones{/number}","notifications_url":"https://api.github.com/repos/google/google-api-nodejs-client/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/google/google-api-nodejs-client/labels{/name}","releases_url":"https://api.github.com/repos/google/google-api-nodejs-client/releases{/id}","created_at":"2013-03-06T17:02:23Z","updated_at":"2015-02-19T02:57:53Z","pushed_at":"2015-02-16T06:51:16Z","git_url":"git://github.com/google/google-api-nodejs-client.git","ssh_url":"git@github.com:google/google-api-nodejs-client.git","clone_url":"https://github.com/google/google-api-nodejs-client.git","svn_url":"https://github.com/google/google-api-nodejs-client","homepage":"","size":3218,"stargazers_count":2783,"watchers_count":2783,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":334,"mirror_url":null,"open_issues_count":26,"forks":334,"open_issues":26,"watchers":2783,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/google/google-api-nodejs-client/pulls/371"},"html":{"href":"https://github.com/google/google-api-nodejs-client/pull/371"},"issue":{"href":"https://api.github.com/repos/google/google-api-nodejs-client/issues/371"},"comments":{"href":"https://api.github.com/repos/google/google-api-nodejs-client/issues/371/comments"},"review_comments":{"href":"https://api.github.com/repos/google/google-api-nodejs-client/pulls/371/comments"},"review_comment":{"href":"https://api.github.com/repos/google/google-api-nodejs-client/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/google/google-api-nodejs-client/pulls/371/commits"},"statuses":{"href":"https://api.github.com/repos/google/google-api-nodejs-client/statuses/449a3bc1e23c2ede18cafa4a150adfafdd61e8f9"}}}}