Преглед изворни кода

Support up to 2mb requests

James Allen пре 12 година
родитељ
комит
79457227e1

+ 1 - 1
services/docstore/app.coffee

@@ -17,7 +17,7 @@ app.use Metrics.http.monitor(logger)
 
 app.get  '/project/:project_id/doc', HttpController.getAllDocs
 app.get  '/project/:project_id/doc/:doc_id', HttpController.getDoc
-app.post '/project/:project_id/doc/:doc_id', bodyParser.json(), HttpController.updateDoc
+app.post '/project/:project_id/doc/:doc_id', bodyParser.json(limit: "2mb"), HttpController.updateDoc
 app.del  '/project/:project_id/doc/:doc_id', HttpController.deleteDoc
 
 app.get '/status', (req, res)->

+ 16 - 0
services/docstore/test/acceptance/coffee/UpdatingDocsTests.coffee

@@ -95,3 +95,19 @@ describe "Applying updates to a doc", ->
 					doc.lines.should.deep.equal @originalLines
 					done()
 
+	describe "when the content is large", ->
+		beforeEach (done) ->
+			line = new Array(1025).join("x") # 1kb
+			@largeLines = Array.apply(null, Array(1024)).map(() -> line) # 1mb
+			DocstoreClient.updateDoc @project_id, @doc_id, @largeLines, @newVersion, (error, res, @body) =>
+				done()
+
+		it "should return modified = true", ->
+			@body.modified.should.equal true
+
+		it "should update the doc in the API", (done) ->
+			DocstoreClient.getDoc @project_id, @doc_id, (error, res, doc) =>
+				doc.lines.should.deep.equal @largeLines
+				doc.version.should.deep.equal @newVersion
+				done()
+