1
0
mirror of https://github.com/square/okhttp.git synced 2025-11-24 18:41:06 +03:00
Commit Graph

76 Commits

Author SHA1 Message Date
Jesse Wilson
030dbeae26 Delete unwanted whitespace.
I think the convert-to-Kotlin feature adds these
2019-05-22 21:12:55 -04:00
monkey-mas
fa9118949e Use idiomatic Kotlin in Request.kt (#5092)
- define @get:JvmName(...) for the following vals in constructor instead of passing builder: Builder.
  - url: HttpUrl
  - method: String
  - headers: Headers
  - body: RequestBody?

- add @Deprecated(...) to the following functions.
  - fun url(): HttpUrl
  - fun method(): String
  - fun headers(): Headers
  - fun body(): RequestBody?
  - fun cacheControl(): CacheControl

- clean up code where ()(Parentheses) is unnecessarily used.
2019-05-22 15:55:00 -04:00
Jake Wharton
8d9b408b57 Kotlin improvements
Around string index/substring/contains and collection contains mostly.
2019-05-20 17:13:24 -04:00
Yuri Schimke
f468cfc7b2 Avoiding direct java.lang usage (#5065)
* i

* i

* i
2019-05-18 06:44:20 -04:00
Jesse Wilson
53e0f9e7fb Adopt idiomatic Kotlin in Headers 2019-05-16 08:32:31 -04:00
Jesse Wilson
b46f891a52 Convert HttpHeaders to Kotlin (#5016)
* Rename HttpHeaders.java to .kt

* Convert HttpHeaders to Kotlin
2019-05-06 20:50:19 -04:00
Yuri Schimke
9f5a96fe7c Fix merge conflicts after spotless applied (#4933) 2019-04-12 21:54:08 +01:00
Yuri Schimke
b89e9ed5c4 Fix kotlin source compatibility with logger (#4927)
* Document broken kotlin source

* Fix existing code
2019-04-12 16:18:34 -04:00
Yuri Schimke
f3949c23bc Spotless code formatter 2019-04-10 22:44:58 +01:00
Yuri Schimke
9e12bc4d60 Improve PlatformRule autodetection (#4920)
Run more platforms in circleci.
Auto detect platform in IDE.
Surface more platform assumptions in tests.
2019-04-10 19:31:35 +01:00
Jesse Wilson
2e947a2202 Cover more of the OkHttp API for source compatibility 2019-04-06 20:58:08 -04:00
Jesse Wilson
18f2b5e6e6 Fix source compatibility for some Kotlin callsites. (#4887)
We had a problem where boolean vals needed to be reverted back to
boolean funs. I'd like to go back to vals later, but supporting existing
source patterns is more important.

We also had a problem where single abstract method types (SAM types)
could be supplied as lambas when calling into Java but not when calling
into Kotlin.

I found these by pointing KotlinSourceCompatibilityTest at the OkHttp

Get there like this:
  git co 7eb897ab2e223632b3316bf46a15d37307a3d3b6^
  git co 7eb897ab2e okhttp/build.gradle
  git co 7eb897ab2e build.gradle
2019-04-06 07:07:11 +01:00
Yuri Schimke
1f93359f15 Run CircleCI with multiple platforms (#4864)
Run in CircleCI.
Also conditionally disables tests that show issues with Conscrypt/OkHttp (client auth etc).
2019-04-03 15:45:05 +01:00
Zac Sweers
b042f1e499 Add Module.md files for different artifacts with module and package info (#4844)
* Add Module.md files for different artifacts with module and package info

This is what dokka uses to document packages and modules. Deleted the `package-info.kt` file as it doesn't do anything on its own, but can restore if it's still wanted

* Add Module.md for mockwebserver

* Only specify module if it exists

A bunch of samples don't have modules or readmes

* Remove package descriptors
2019-04-02 07:27:49 -04:00
Jake Wharton
0e9a5c8054 Make error-prone validate missing override annotations 2019-03-31 13:04:22 -04:00
Yuri Schimke
02914fbba1 Kotlin version of logging-interceptor (#4820) 2019-03-30 22:22:28 +00:00
Jesse Wilson
dedc6ecd5b Use more AssertJ features 2019-03-14 17:57:42 -04:00
Benoît Quenaudon
6c4855a7c7 Use AssertJ in tests (#4713) 2019-03-13 21:07:33 -04:00
Galder Zamarreño
ee011b71cf More flexible cipherSuite matching #4685
* Match any cipher suites starting with TLS_
2019-03-06 09:07:22 +01:00
Jesse Wilson
38eb03457c Don't log duplex request bodies
We may want to support these eventually but for now this is
unhelpful because they won't terminate.
2019-02-26 22:06:31 -05:00
Jesse Wilson
aac6c8da07 Introduce EventListener.requestFailed, responseFailed events
These replace requestBodyEnd() / responseBodyEnd() in some failure scenarios.
They may also be issued in cases where no event was published previously.
2019-02-23 18:39:11 -05:00
Yuri Schimke
50df11c471 Build with 3 JDK targets (#4568)
* Build with 3 targets

* Update maven

* remove jdk 12 ea

* Try without errorprone temporarily

* Still set 1.8

* javadoc tolerance

* Profiles for 10 + 11

* More tolerant

* JDK 11 test skipping

* Cleanup imports

* Link to github issues

* Support JDK 12 building
2019-02-09 07:32:49 -05:00
Jesse Wilson
778e0334a4 Use lambdas where appropriate 2019-01-11 22:31:36 -05:00
Jesse Wilson
5f4a2642c0 Use automatic-resource-management blocks. 2019-01-01 21:50:44 -05:00
Jesse Wilson
0dc50f1112 Run IntelliJ inspections on the codebase
Some nullability warnings, some diamond operators, adopting Objects.equals(),
and some dead code elimination.
2019-01-01 12:41:06 -05:00
Yuri Schimke
f38c74130d Log handshake in LoggingEventListener (#4397) 2018-11-20 05:44:20 +00:00
Amir Livneh
1f7e796e6e Cleanup HttpLoggingInterceptor (#4346)
* Use try-with-resources

* Make bodyHasUnknownEncoding() static

* Fix nits in HttpLoggingInterceptorTest

* Revert "Use try-with-resources"

This reverts commit 57dcd61a9e.
2018-11-14 23:29:45 -05:00
Amir Livneh
ef34a41d09 Add a LoggingEventListener and use it in okcurl (#4353)
* Add LoggingEventListener and use it in okcurl

* Fix tests failing in IP6 environment

* Make less assumptions about test environment

* Disable retry in test to make test sequence more predictable

* Fix javadoc compilation

There seems to be inconsistency between javdoc parsing between 'mvn verify' and Travis CI. Before the change, 'mvn clean verify' passes but Travis CI fails due to missing import of okhttp3.OkHttpClient. Just adding the missing import, causes 'mvn verify' to fail die to unused import. Changing the line wrapping seems to appease 'mvn verify'.

* Address comments

* Remove unused imports
2018-11-13 21:58:22 -05:00
Yuri Schimke
ceb42f1322 EverythingIsNonNull annotation (#4286)
Adds an annotation EverythingIsNonNull, and fixes some nullability on public API.
2018-09-30 09:33:42 +01:00
Amir Livneh
d2ddd4ef9d Support header redaction in HttpLoggingInterceptor (#4287)
Add redactHeader() method that allows clients to mark (case insensitive) headers carrying private data that can't be logged.
2018-09-24 19:44:56 +01:00
Jesse Wilson
37887141fe Rename TlsNode to HandshakeCertificates (#4141) 2018-07-12 06:39:20 +01:00
Jesse Wilson
b1bfe7130c New okhttp-tls module 2018-07-09 12:00:28 -04:00
Jesse Wilson
31c511f694 Rename SslClient to TlsNode and make it a public API
https://github.com/square/okhttp/issues/3934
2018-07-08 15:33:16 -04:00
Jake Wharton
36f4fd04f7 Add parse overload which fails on invalid inputs 2018-07-05 23:18:15 -04:00
Jesse Wilson
d0418379a7 Move MockWebServer's internal package to not collide with OkHttp's. (#3837)
Hoping this may prevent problems with the Java Platform Module System.
2018-02-09 06:20:57 +00:00
Matt Sheppard
bb304b9c2c Log gzipped bodies when HttpLoggingInterceptor is used as a NetworkInterceptor (#3792)
* (in-progress) Support gzipped bodies as a networkInterceptor

* Fixed buffer cloning, added test for a still-unsupported encoding (Brotli)

* Avoid try-with-resources and too-long lines to appease build checks

* Fixed method name typo

* Added suggested comma between byte and gzipped-byte count

* Account for added comma in test

* Use buffer.writeAll to ensure all body content is read

* Indentation consistency

* Added test to confirm response body remains valid
2018-01-28 11:33:00 -05:00
Jesse Wilson
207f5579d3 Omit the message from MockWebServer's HTTP/2 :status header (#3556)
This was a bug carried over from SPDY.

Closes: https://github.com/square/okhttp/issues/3484
2017-08-30 18:25:44 -04:00
Jesse Wilson
16f43b6439 Don't log a protocol when it is unknown. (#3558)
Closes: https://github.com/square/okhttp/issues/3395
2017-08-30 14:04:53 -04:00
jwilson
011b2ee76d Import jsr305 and use it to mark @Nullable stuff.
This library is a provided dependency and is not necessary to be included
by OkHttp users.

This currently covers the okhttp and okhttp-logging-interceptor modules
only. It does not cover the 'internal' package in OkHttp, or its test cases.
We can add those as needed.
2017-05-06 15:25:55 -04:00
jwilson
6651a9c15e Change MediaType's failure mode to not crash on charset problems.
As-is it throws unchecked exceptions on unexpected charsets. This is a problem
because it can cause a misbehaving webserver to crash the client.

I don't expect this to break existing clients; returning 'null' has always
been a possibility; it's just returned in more cases.
2017-01-29 13:46:30 -05:00
Frieder Bluemle
f4f5ca9a8d Fix logging-interceptor Javadoc typo 2016-07-05 19:08:16 +08:00
jwilson
a4d3082d2f Run IntelliJ's analysis on OkHttp.
This made a few hundred suggestions, many of which are thoughtful but
I'm deliberately ignoring anyway.

The following fixes are good ideas.
2016-06-27 00:47:50 -04:00
jwilson
c5187583bb Add connection, cache, and platform subpackages. 2016-06-26 23:04:30 -04:00
jwilson
e3b3180f9c Split HttpEngine into 3 interceptors.
BridgeInterceptor does some basic header management and implements gzip
on responses.

CacheInterceptor implements HTTP response caching.

ConnectInterceptor takes the StreamAllocation that's already allocated
and uses it to create an HttpStream.
2016-06-26 10:27:34 -04:00
jwilson
8271dc0fb1 Fix HttpLoggingInterceptor to be cool with newlines.
Unfortunately our plaintext detector treats \r and \n as non-plaintext
characters, and they're completely fine.

Closes: https://github.com/square/okhttp/issues/2579
2016-05-28 10:49:31 -04:00
Andy Dennie
f1dea26fd6 update Logging Interceptor to log connection failures 2016-05-14 13:21:09 -04:00
Jake Wharton
276ef646cd Merge pull request #2544 from square/jwilson.0508.no_synthetic_headers
Promote sent and received timestamps to fields on Response.
2016-05-09 00:03:38 -04:00
jwilson
bab8943f2b Promote sent and received timestamps to fields on Response.
I'm currently keeping these as longs. That's easy an unambiguous, but it also
feels rather primitive.

This was more work than I expected, but it doesn't seem particularly risky.
It's also potentially more efficient, since there's fewer places where we're
converting from string to long and vice versa.

Closes: https://github.com/square/okhttp/issues/2035
2016-05-08 15:25:56 -04:00
jwilson
4f24a30c12 Make logging more consistent throughout OkHttp.
Avoid using System.out.

Use the best logging implementation on the host platform. On Java this is
java.util.logging. On Android it's Android.util.Log.

Closes https://github.com/square/okhttp/issues/2505
2016-05-07 21:08:37 -04:00
Alex Wegener
e0c2795bae Log plain text bodies only 2016-03-03 21:55:25 -05:00