Coder Social home page Coder Social logo

Comments (12)

swankjesse avatar swankjesse commented on June 8, 2024

I don’t believe the behavior has changed in OkHttp 4.12.0.

We’ve got a test case in 4.12.0 that hasn’t changed since December 8, 2019.
https://github.com/square/okhttp/blob/okhttp_4x/okhttp/src/test/java/okhttp3/FormBodyTest.java#L26

But we did change it in 5.0.0-alpha.2, and I announced that in our changelog:
https://github.com/square/okhttp/pull/6518/files
https://square.github.io/okhttp/changelogs/changelog/#version-500-alpha2

Is it possible you’re running the 5.0 release unexpectedly, perhaps via a transitive dependency?

Either way I’m sorry for the disruption, and we don’t make breaking changes lightly.

from okhttp.

jimshowalter avatar jimshowalter commented on June 8, 2024

It appears we mixed mockwebserver alpha 5 with okhttp 4.12.0.

Oddly, it works, but we'd prefer to use com.squareup.okhttp3:mockwebserver:4.12.0.

But when we try to do that, there's no okhttp3.mockwebserver.MockWebServerExtension.

Is there some other non-5/non-alpha jar we need to add to get the equivalent of a JUnit 5 extension class for mockwebserver 4.12.0?

from okhttp.

jimshowalter avatar jimshowalter commented on June 8, 2024

We'd love to use your v5 alpha jars, but we have to keep dependencies aligned with the latest Spring and Spring Boot, and they're on 4.12.0.

from okhttp.

swankjesse avatar swankjesse commented on June 8, 2024

One of the main goals of OkHttp 5.x is to fix our longstanding bug where MockWebServer is strongly coupled with JUnit 4.

from okhttp.

swankjesse avatar swankjesse commented on June 8, 2024

I’ll do what I can to get 5.0 final out soon, which will hopefully be taken up quickly by our Spring friends.

from okhttp.

jimshowalter avatar jimshowalter commented on June 8, 2024

Is there some way to use mockwebserver alpha 5 without changing the form body?

from okhttp.

swankjesse avatar swankjesse commented on June 8, 2024

Could you please elaborate on the problem with the new behaviour? According to the PR that changed it, the new behaviour is closer to what the specs expect.

from okhttp.

RonakWithCode avatar RonakWithCode commented on June 8, 2024

In version 4.12.0, there was a change in form body encoding where spaces are now represented as %20 instead of the plus sign (+). Check the release notes or documentation for details, and update your code accordingly for compatibility.

from okhttp.

swankjesse avatar swankjesse commented on June 8, 2024

@RonakWithCode there was no such behaviour change in 4.12. Please see the comment above.

from okhttp.

jimshowalter avatar jimshowalter commented on June 8, 2024

The mystery is that:

  • We're on 4.12.0 for everything except mockwebserver.
  • We have Gradle forces for okhttp, and they work even for mockwebserver, as shown in the output from gradlew dependencies:

--- com.squareup.okhttp3:mockwebserver3-junit5:5.0.0-alpha.2
+--- com.squareup.okhttp3:mockwebserver3:5.0.0-alpha.2
| +--- com.squareup.okhttp3:okhttp:5.0.0-alpha.2 -> 4.12.0

  • The behavior of our form-body test changed from + to %20.
  • Our form-body test doesn't even use mockwebserver:

package com.foo;

import jakarta.annotation.Nullable;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import okhttp3.MediaType;
import okhttp3.RequestBody;
import okhttp3.internal.Util;

public abstract class FooRequestBody {...

package com.foo;

import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.IllegalCharsetNameException;
import java.nio.charset.UnsupportedCharsetException;
import okhttp3.FormBody;

public class FooFormBody extends FooRequestBody {...

package com.foo;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.io.IOException;
import okio.Buffer;
import org.junit.jupiter.api.Test;

class FooFormBodyTest {
private FooFormBody body;

Screenshot 2023-12-20 at 2 43 29 PM

from okhttp.

yschimke avatar yschimke commented on June 8, 2024

Can you reproduce in a minimal build with only 4.12.0?

Otherwise it points to an issue with your gradle build still lying about the version.

from okhttp.

yschimke avatar yschimke commented on June 8, 2024

Closing for now as we have tests for this, will reopen if we can repro it failing on 4.12.0

from okhttp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.