@@ -20,15 +20,11 @@ trait Compress {
20
20
}
21
21
object Compress {
22
22
object Gzip extends Compress {
23
- def headers = Seq (
24
- " Content-Encoding" -> " gzip"
25
- )
23
+ def headers = Seq (" Content-Encoding" -> " gzip" )
26
24
def wrap (x : OutputStream ) = new GZIPOutputStream (x)
27
25
}
28
26
object Deflate extends Compress {
29
- def headers = Seq (
30
- " Content-Encoding" -> " deflate"
31
- )
27
+ def headers = Seq (" Content-Encoding" -> " deflate" )
32
28
def wrap (x : OutputStream ) = new DeflaterOutputStream (x)
33
29
}
34
30
object None extends Compress {
@@ -59,7 +55,7 @@ case class Request(
59
55
autoDecompress : Boolean = true ,
60
56
compress : Compress = Compress .None ,
61
57
keepAlive : Boolean = true ,
62
- check : Boolean = true
58
+ check : Boolean = true ,
63
59
)
64
60
65
61
/**
@@ -90,15 +86,14 @@ object RequestBlob {
90
86
implicit class FileRequestBlob (x : java.io.File ) extends RequestBlob {
91
87
override def headers = super .headers ++ Seq (
92
88
" Content-Type" -> " application/octet-stream" ,
93
- " Content-Length" -> x.length().toString
89
+ " Content-Length" -> x.length().toString,
94
90
)
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)
97
92
}
98
93
implicit class NioFileRequestBlob (x : java.nio.file.Path ) extends RequestBlob {
99
94
override def headers = super .headers ++ Seq (
100
95
" 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,
102
97
)
103
98
def write (out : java.io.OutputStream ) =
104
99
Util .transferTo(java.nio.file.Files .newInputStream(x), out)
@@ -107,7 +102,7 @@ object RequestBlob {
107
102
implicit class FormEncodedRequestBlob (val x : Iterable [(String , String )]) extends RequestBlob {
108
103
val serialized = Util .urlEncode(x).getBytes
109
104
override def headers = super .headers ++ Seq (
110
- " Content-Type" -> " application/x-www-form-urlencoded"
105
+ " Content-Type" -> " application/x-www-form-urlencoded" ,
111
106
)
112
107
def write (out : java.io.OutputStream ) = {
113
108
out.write(serialized)
@@ -128,30 +123,30 @@ object RequestBlob {
128
123
(
129
124
p.name.getBytes(),
130
125
if (p.filename == null ) Array [Byte ]() else p.filename.getBytes(),
131
- p
132
- )
126
+ p,
127
+ ),
133
128
)
134
129
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" )
138
131
def write (out : java.io.OutputStream ) = {
139
132
def writeBytes (s : String ): Unit = out.write(s.getBytes())
140
133
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)
155
150
}
156
151
157
152
writeBytes(pref + boundary + pref + crlf)
@@ -204,7 +199,7 @@ case class Response(
204
199
statusMessage : String ,
205
200
data : geny.Bytes ,
206
201
headers : Map [String , Seq [String ]],
207
- history : Option [Response ]
202
+ history : Option [Response ],
208
203
) extends geny.ByteData
209
204
with geny.Readable {
210
205
@@ -247,7 +242,7 @@ case class StreamHeaders(
247
242
@ deprecated(" Value is inferred from `statusCode`" , " 0.9.0" )
248
243
statusMessage : String ,
249
244
headers : Map [String , Seq [String ]],
250
- history : Option [Response ]
245
+ history : Option [Response ],
251
246
) {
252
247
def is2xx = statusCode.toString.charAt(0 ) == '2'
253
248
def is3xx = statusCode.toString.charAt(0 ) == '3'
@@ -270,14 +265,13 @@ object RequestAuth {
270
265
implicit def implicitBasic (x : (String , String )): Basic = new Basic (x._1, x._2)
271
266
class Basic (username : String , password : String ) extends RequestAuth {
272
267
def header = Some (
273
- " Basic " + java.util.Base64 .getEncoder
274
- .encodeToString((username + " :" + password).getBytes())
268
+ " Basic " + java.util.Base64 .getEncoder.encodeToString((username + " :" + password).getBytes()),
275
269
)
276
270
}
277
271
case class Proxy (username : String , password : String ) extends RequestAuth {
278
272
def header = Some (
279
273
" Proxy-Authorization " + java.util.Base64 .getEncoder
280
- .encodeToString((username + " :" + password).getBytes())
274
+ .encodeToString((username + " :" + password).getBytes()),
281
275
)
282
276
}
283
277
case class Bearer (token : String ) extends RequestAuth {
0 commit comments