File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ case class Req(
63
63
}
64
64
65
65
object Req {
66
- final case class Properties (bodyType : BodyType = NoBody )
66
+ final case class Properties (bodyType : BodyType = NoBody , methodExplicitlySet : Boolean = false )
67
67
68
68
trait BodyType
69
69
final case object NoBody extends BodyType
@@ -409,21 +409,18 @@ trait RequestBuilderVerbs extends RequestVerbs {
409
409
) }
410
410
}
411
411
412
- private [this ] var methodExplicitlySet : Boolean = false
413
-
414
412
/**
415
413
* Explicitly set the method of the request.
416
414
*/
417
415
def setMethod (method : String ) = {
418
- methodExplicitlySet = true
419
- subject.underlying(_.setMethod(method))
416
+ subject.underlying(_.setMethod(method), _.copy(methodExplicitlySet = true ))
420
417
}
421
418
422
419
/**
423
420
* Set method unless method has been explicitly set using [[setMethod ]].
424
421
*/
425
422
def implyMethod (method : String ) = {
426
- if (! methodExplicitlySet) {
423
+ if (! subject.props. methodExplicitlySet) {
427
424
subject.underlying(_.setMethod(method))
428
425
} else {
429
426
subject
Original file line number Diff line number Diff line change @@ -96,6 +96,20 @@ with DispatchCleanup {
96
96
res() ?= (" POST" + sample)
97
97
}
98
98
99
+ property(" PUT alphaString body with setBody and get response" ) = forAll(Gen .alphaStr) { (sample : String ) =>
100
+ val res = Http .default(
101
+ (localhost / " echobody" ).PUT .setBody(sample) > as.String
102
+ )
103
+ res() ?= (" PUT" + sample)
104
+ }
105
+
106
+ property(" PUT alphaString body with << and get response" ) = forAll(Gen .alphaStr) { (sample : String ) =>
107
+ val res = Http .default(
108
+ (localhost / " echobody" ).PUT << sample > as.String
109
+ )
110
+ res() ?= (" PUT" + sample)
111
+ }
112
+
99
113
property(" GET and handle" ) = forAll(Gen .alphaStr) { (sample : String ) =>
100
114
val res = Http .default(
101
115
localhost / " echo" <<? Map (" echo" -> sample) > as.String
You can’t perform that action at this time.
0 commit comments