Skip to content

Commit

Permalink
finatra-http: add an additional http post helper for tests
Browse files Browse the repository at this point in the history
Summary: Problem

It is not possible to create a non-multipart post request with repeating params e.g.

    curl -X POST http://example.com/post_endpoint -d foo=bar -d foo=baz

since the httpFormPost param arg is of type Map[String, String]

Solution

Add an additional multipart boolean param to method httpMultipartFormPost
that is passed on to formPost

Differential Revision: https://phabricator.twitter.biz/D113151
  • Loading branch information
Sumit Shah authored and jenkins committed Nov 18, 2017
1 parent 5eb8e4b commit c139d95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ All notable changes to this project will be documented in this file. Note that `

### Changed

* finatra-http: add a `multipart = true` arg to
`EmbeddedHttpServer.httpMultipartFormPost`
``PHAB_ID=D113151`
* inject-sever: Do not use the `c.t.inject.server.EmbeddedTwitterServer`
`InMemoryStatsReceiver` for embedded http clients. The http client stats are
emitted with the server under test stats which can be confusing, thus we now
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,7 @@ class EmbeddedHttpServer(
*
* @param path - URI of the request
* @param params - a Seq of [[com.twitter.finagle.http.FormElement]] to send in the request
* @param multipart - if this form post is a multi-part request, true by default
* @param routeToAdminServer - force the request to the admin interface of the embedded server, false by default.
* @param headers - additional headers that should be passed with the request
* @param andExpect - expected [[com.twitter.finagle.http.Status]] value
Expand All @@ -937,6 +938,7 @@ class EmbeddedHttpServer(
def httpMultipartFormPost(
path: String,
params: Seq[FormElement],
multipart: Boolean = true,
routeToAdminServer: Boolean = false,
headers: Map[String, String] = Map.empty,
andExpect: Status = Status.Ok,
Expand All @@ -948,7 +950,7 @@ class EmbeddedHttpServer(
formPost(
path = path,
params = params,
multipart = true,
multipart = multipart,
routeToAdminServer = routeToAdminServer,
headers = headers,
andExpect = andExpect,
Expand Down

0 comments on commit c139d95

Please sign in to comment.