Skip to content

Commit 3cbdfb4

Browse files
Merge pull request #66 from jodersky/master
Prepare for inclusion in dotty-community build
2 parents 66afcdf + a6af276 commit 3cbdfb4

File tree

5 files changed

+40
-38
lines changed

5 files changed

+40
-38
lines changed

build.sc

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import mill._
22
import mill.scalalib.publish.{Developer, License, PomSettings, VersionControl}
33
import scalalib._
44

5-
object requests extends Cross[RequestsModule]("2.12.6", "2.13.0")
5+
val dottyVersion = Option(sys.props("dottyVersion"))
6+
7+
object requests extends Cross[RequestsModule]((List("2.12.6", "2.13.0", "0.26.0-RC1") ++ dottyVersion): _*)
68
class RequestsModule(val crossScalaVersion: String) extends CrossScalaModule with PublishModule {
79
def publishVersion = "0.6.5"
810
def artifactName = "requests"
@@ -21,7 +23,7 @@ class RequestsModule(val crossScalaVersion: String) extends CrossScalaModule wit
2123
)
2224
object test extends Tests{
2325
def ivyDeps = Agg(
24-
ivy"com.lihaoyi::utest::0.7.3",
26+
ivy"com.lihaoyi::utest::0.7.4",
2527
ivy"com.lihaoyi::ujson::1.1.0"
2628
)
2729
def testFrameworks = Seq("utest.runner.Framework")

mill

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# This is a wrapper script, that automatically download mill from GitHub release pages
44
# You can give the required mill version with MILL_VERSION env variable
55
# If no version is given, it falls back to the value of DEFAULT_MILL_VERSION
6-
DEFAULT_MILL_VERSION=0.7.3
6+
DEFAULT_MILL_VERSION=0.8.0
77

88
set -e
99

requests/src/requests/Model.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ object RequestAuth{
244244
object Empty extends RequestAuth{
245245
def header = None
246246
}
247-
implicit def implicitBasic(x: (String, String)) = new Basic(x._1, x._2)
247+
implicit def implicitBasic(x: (String, String)): Basic = new Basic(x._1, x._2)
248248
class Basic(username: String, password: String) extends RequestAuth{
249249
def header = Some("Basic " + java.util.Base64.getEncoder.encodeToString((username + ":" + password).getBytes()))
250250
}
@@ -258,7 +258,7 @@ object RequestAuth{
258258

259259
sealed trait Cert
260260
object Cert{
261-
implicit def implicitP12(path: String) = P12(path, None)
262-
implicit def implicitP12(x: (String, String)) = P12(x._1, Some(x._2))
261+
implicit def implicitP12(path: String): P12 = P12(path, None)
262+
implicit def implicitP12(x: (String, String)): P12 = P12(x._1, Some(x._2))
263263
case class P12(p12: String, pwd: Option[String] = None) extends Cert
264264
}

requests/src/requests/Requester.scala

+15-15
Original file line numberDiff line numberDiff line change
@@ -187,21 +187,21 @@ case class Requester(verb: String,
187187
url1.openConnection(p)
188188
}
189189

190-
connection = conn match{
191-
case c: HttpsURLConnection =>
192-
if (cert != null) {
193-
c.setSSLSocketFactory(Util.clientCertSocketFactory(cert, verifySslCerts))
194-
if (!verifySslCerts) c.setHostnameVerifier((_: String, _: SSLSession) => true)
195-
} else if (sslContext != null) {
196-
c.setSSLSocketFactory(sslContext.getSocketFactory)
197-
if (!verifySslCerts) c.setHostnameVerifier((_: String, _: SSLSession) => true)
198-
} else if (!verifySslCerts) {
199-
c.setSSLSocketFactory(Util.noVerifySocketFactory)
200-
c.setHostnameVerifier((_: String, _: SSLSession) => true)
201-
}
202-
c
203-
case c: HttpURLConnection => c
204-
}
190+
connection = conn match{
191+
case c: HttpsURLConnection =>
192+
if (cert != null) {
193+
c.setSSLSocketFactory(Util.clientCertSocketFactory(cert, verifySslCerts))
194+
if (!verifySslCerts) c.setHostnameVerifier((_: String, _: SSLSession) => true)
195+
} else if (sslContext != null) {
196+
c.setSSLSocketFactory(sslContext.getSocketFactory)
197+
if (!verifySslCerts) c.setHostnameVerifier((_: String, _: SSLSession) => true)
198+
} else if (!verifySslCerts) {
199+
c.setSSLSocketFactory(Util.noVerifySocketFactory)
200+
c.setHostnameVerifier((_: String, _: SSLSession) => true)
201+
}
202+
c
203+
case c: HttpURLConnection => c
204+
}
205205

206206
connection.setInstanceFollowRedirects(false)
207207
val upperCaseVerb = verb.toUpperCase

requests/test/src/requests/RequestTests.scala

+17-17
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ object RequestTests extends TestSuite{
3333
test("params"){
3434
test("get"){
3535
// All in URL
36-
val res1 = requests.get("https://httpbin.org/get?hello=world&foo=baz").text
36+
val res1 = requests.get("https://httpbin.org/get?hello=world&foo=baz").text()
3737
assert(read(res1).obj("args") == Obj("foo" -> "baz", "hello" -> "world"))
3838

3939
// All in params
@@ -47,7 +47,7 @@ object RequestTests extends TestSuite{
4747
val res3 = requests.get(
4848
"https://httpbin.org/get?hello=world",
4949
params = Map("foo" -> "baz")
50-
).text
50+
).text()
5151
assert(read(res3).obj("args") == Obj("foo" -> "baz", "hello" -> "world"))
5252

5353
// Needs escaping
@@ -63,7 +63,7 @@ object RequestTests extends TestSuite{
6363
"https://httpbin.org/post",
6464
data = Map("hello" -> "world", "foo" -> "baz"),
6565
chunkedUpload = chunkedUpload
66-
).text
66+
).text()
6767
assert(read(res1).obj("form") == Obj("foo" -> "baz", "hello" -> "world"))
6868
}
6969
}
@@ -73,7 +73,7 @@ object RequestTests extends TestSuite{
7373
"https://httpbin.org/put",
7474
data = Map("hello" -> "world", "foo" -> "baz"),
7575
chunkedUpload = chunkedUpload
76-
).text
76+
).text()
7777
assert(read(res1).obj("form") == Obj("foo" -> "baz", "hello" -> "world"))
7878
}
7979
}
@@ -87,7 +87,7 @@ object RequestTests extends TestSuite{
8787
MultiItem("file2", "Goodbye!")
8888
),
8989
chunkedUpload = chunkedUpload
90-
).text
90+
).text()
9191

9292
assert(read(response).obj("files") == Obj("file1" -> "Hello!"))
9393
assert(read(response).obj("form") == Obj("file2" -> "Goodbye!"))
@@ -97,17 +97,17 @@ object RequestTests extends TestSuite{
9797

9898
test("session"){
9999
val s = requests.Session(cookieValues = Map("hello" -> "world"))
100-
val res1 = s.get("https://httpbin.org/cookies").text.trim
100+
val res1 = s.get("https://httpbin.org/cookies").text().trim
101101
assert(read(res1) == Obj("cookies" -> Obj("hello" -> "world")))
102102
s.get("https://httpbin.org/cookies/set?freeform=test")
103-
val res2 = s.get("https://httpbin.org/cookies").text.trim
103+
val res2 = s.get("https://httpbin.org/cookies").text().trim
104104
assert(read(res2) == Obj("cookies" -> Obj("freeform" -> "test", "hello" -> "world")))
105105
}
106106
test("raw"){
107-
val res1 = requests.get("https://httpbin.org/cookies").text.trim
107+
val res1 = requests.get("https://httpbin.org/cookies").text().trim
108108
assert(read(res1) == Obj("cookies" -> Obj()))
109109
requests.get("https://httpbin.org/cookies/set?freeform=test")
110-
val res2 = requests.get("https://httpbin.org/cookies").text.trim
110+
val res2 = requests.get("https://httpbin.org/cookies").text().trim
111111
assert(read(res2) == Obj("cookies" -> Obj()))
112112
}
113113
}
@@ -134,9 +134,9 @@ object RequestTests extends TestSuite{
134134
}
135135
}
136136
test("streaming"){
137-
val res1 = requests.get("http://httpbin.org/stream/5").text
137+
val res1 = requests.get("http://httpbin.org/stream/5").text()
138138
assert(res1.linesIterator.length == 5)
139-
val res2 = requests.get("http://httpbin.org/stream/52").text
139+
val res2 = requests.get("http://httpbin.org/stream/52").text()
140140
assert(res2.linesIterator.length == 52)
141141
}
142142
test("timeouts"){
@@ -171,7 +171,7 @@ object RequestTests extends TestSuite{
171171
}
172172
test("decompress"){
173173
val res1 = requests.get("https://httpbin.org/gzip")
174-
assert(read(res1.text).obj("headers").obj("Host").str == "httpbin.org")
174+
assert(read(res1.text()).obj("headers").obj("Host").str == "httpbin.org")
175175

176176
val res2 = requests.get("https://httpbin.org/deflate")
177177
assert(read(res2).obj("headers").obj("Host").str == "httpbin.org")
@@ -190,26 +190,26 @@ object RequestTests extends TestSuite{
190190
compress = requests.Compress.None,
191191
data = "Hello World"
192192
)
193-
assert(res1.text.contains(""""Hello World""""))
193+
assert(res1.text().contains(""""Hello World""""))
194194

195195
val res2 = requests.post(
196196
"https://httpbin.org/post",
197197
compress = requests.Compress.Gzip,
198198
data = "I am cow"
199199
)
200-
assert(res2.text.contains("data:application/octet-stream;base64,H4sIAAAAAAAAAA=="))
200+
assert(res2.text().contains("data:application/octet-stream;base64,H4sIAAAAAAAAAA=="))
201201

202202
val res3 = requests.post(
203203
"https://httpbin.org/post",
204204
compress = requests.Compress.Deflate,
205205
data = "Hear me moo"
206206
)
207-
assert(res3.text.contains("data:application/octet-stream;base64,eJw="))
208-
res3.text
207+
assert(res3.text().contains("data:application/octet-stream;base64,eJw="))
208+
res3.text()
209209
}
210210
test("headers"){
211211
test("default"){
212-
val res = requests.get("https://httpbin.org/headers").text
212+
val res = requests.get("https://httpbin.org/headers").text()
213213
val hs = read(res)("headers").obj
214214
assert(hs("User-Agent").str == "requests-scala")
215215
assert(hs("Accept-Encoding").str == "gzip, deflate")

0 commit comments

Comments
 (0)