@@ -20,15 +20,11 @@ trait Compress {
2020}
2121object Compress {
2222 object Gzip extends Compress {
23- def headers = Seq (
24- " Content-Encoding" -> " gzip"
25- )
23+ def headers = Seq (" Content-Encoding" -> " gzip" )
2624 def wrap (x : OutputStream ) = new GZIPOutputStream (x)
2725 }
2826 object Deflate extends Compress {
29- def headers = Seq (
30- " Content-Encoding" -> " deflate"
31- )
27+ def headers = Seq (" Content-Encoding" -> " deflate" )
3228 def wrap (x : OutputStream ) = new DeflaterOutputStream (x)
3329 }
3430 object None extends Compress {
@@ -59,7 +55,7 @@ case class Request(
5955 autoDecompress : Boolean = true ,
6056 compress : Compress = Compress .None ,
6157 keepAlive : Boolean = true ,
62- check : Boolean = true
58+ check : Boolean = true ,
6359)
6460
6561/**
@@ -90,15 +86,14 @@ object RequestBlob {
9086 implicit class FileRequestBlob (x : java.io.File ) extends RequestBlob {
9187 override def headers = super .headers ++ Seq (
9288 " Content-Type" -> " application/octet-stream" ,
93- " Content-Length" -> x.length().toString
89+ " Content-Length" -> x.length().toString,
9490 )
95- def write (out : java.io.OutputStream ) =
96- Util .transferTo(new FileInputStream (x), out)
91+ def write (out : java.io.OutputStream ) = Util .transferTo(new FileInputStream (x), out)
9792 }
9893 implicit class NioFileRequestBlob (x : java.nio.file.Path ) extends RequestBlob {
9994 override def headers = super .headers ++ Seq (
10095 " Content-Type" -> " application/octet-stream" ,
101- " Content-Length" -> java.nio.file.Files .size(x).toString
96+ " Content-Length" -> java.nio.file.Files .size(x).toString,
10297 )
10398 def write (out : java.io.OutputStream ) =
10499 Util .transferTo(java.nio.file.Files .newInputStream(x), out)
@@ -107,7 +102,7 @@ object RequestBlob {
107102 implicit class FormEncodedRequestBlob (val x : Iterable [(String , String )]) extends RequestBlob {
108103 val serialized = Util .urlEncode(x).getBytes
109104 override def headers = super .headers ++ Seq (
110- " Content-Type" -> " application/x-www-form-urlencoded"
105+ " Content-Type" -> " application/x-www-form-urlencoded" ,
111106 )
112107 def write (out : java.io.OutputStream ) = {
113108 out.write(serialized)
@@ -128,30 +123,30 @@ object RequestBlob {
128123 (
129124 p.name.getBytes(),
130125 if (p.filename == null ) Array [Byte ]() else p.filename.getBytes(),
131- p
132- )
126+ p,
127+ ),
133128 )
134129
135- override def headers = Seq (
136- " Content-Type" -> s " multipart/form-data; boundary= $boundary"
137- )
130+ override def headers = Seq (" Content-Type" -> s " multipart/form-data; boundary= $boundary" )
138131 def write (out : java.io.OutputStream ) = {
139132 def writeBytes (s : String ): Unit = out.write(s.getBytes())
140133
141- partBytes.foreach { case (name, filename, part) =>
142- writeBytes(pref + boundary + crlf)
143- part.data.headers.foreach { case (headerName, headerValue) =>
144- writeBytes(s " $headerName: $headerValue$crlf" )
145- }
146- writeBytes(ContentDisposition )
147- out.write(name)
148- if (filename.nonEmpty) {
149- writeBytes(filenameSnippet)
150- out.write(filename)
151- }
152- writeBytes(" \" " + crlf + crlf)
153- part.data.write(out)
154- writeBytes(crlf)
134+ partBytes.foreach {
135+ case (name, filename, part) =>
136+ writeBytes(pref + boundary + crlf)
137+ part.data.headers.foreach {
138+ case (headerName, headerValue) =>
139+ writeBytes(s " $headerName: $headerValue$crlf" )
140+ }
141+ writeBytes(ContentDisposition )
142+ out.write(name)
143+ if (filename.nonEmpty) {
144+ writeBytes(filenameSnippet)
145+ out.write(filename)
146+ }
147+ writeBytes(" \" " + crlf + crlf)
148+ part.data.write(out)
149+ writeBytes(crlf)
155150 }
156151
157152 writeBytes(pref + boundary + pref + crlf)
@@ -204,7 +199,7 @@ case class Response(
204199 statusMessage : String ,
205200 data : geny.Bytes ,
206201 headers : Map [String , Seq [String ]],
207- history : Option [Response ]
202+ history : Option [Response ],
208203) extends geny.ByteData
209204 with geny.Readable {
210205
@@ -247,7 +242,7 @@ case class StreamHeaders(
247242 @ deprecated(" Value is inferred from `statusCode`" , " 0.9.0" )
248243 statusMessage : String ,
249244 headers : Map [String , Seq [String ]],
250- history : Option [Response ]
245+ history : Option [Response ],
251246) {
252247 def is2xx = statusCode.toString.charAt(0 ) == '2'
253248 def is3xx = statusCode.toString.charAt(0 ) == '3'
@@ -270,14 +265,13 @@ object RequestAuth {
270265 implicit def implicitBasic (x : (String , String )): Basic = new Basic (x._1, x._2)
271266 class Basic (username : String , password : String ) extends RequestAuth {
272267 def header = Some (
273- " Basic " + java.util.Base64 .getEncoder
274- .encodeToString((username + " :" + password).getBytes())
268+ " Basic " + java.util.Base64 .getEncoder.encodeToString((username + " :" + password).getBytes()),
275269 )
276270 }
277271 case class Proxy (username : String , password : String ) extends RequestAuth {
278272 def header = Some (
279273 " Proxy-Authorization " + java.util.Base64 .getEncoder
280- .encodeToString((username + " :" + password).getBytes())
274+ .encodeToString((username + " :" + password).getBytes()),
281275 )
282276 }
283277 case class Bearer (token : String ) extends RequestAuth {
0 commit comments