Giter Club home page Giter Club logo

Comments (5)

kongzue avatar kongzue commented on June 15, 2024

您好,请使用 HttpUrl 创建,在传入 url 参数时使用 httpUrl.toString():

HttpUrl httpUrl= new HttpUrl.Builder()
    .scheme("https")
    .host("www.example.com")
    .addQueryParameter("key", "value")
    .build();

请求时:

HttpRequest.build(context, httpUrl.toString())
        .setResponseListener(new ResponseListener() {
            @Override
            public void onResponse(String response, Exception error) {
                ...
            }
        })
        .doPost();

from baseokhttpv3.

honganxue avatar honganxue commented on June 15, 2024

host 传入ip地址报错

from baseokhttpv3.

kongzue avatar kongzue commented on June 15, 2024

请说明是什么错误

from baseokhttpv3.

honganxue avatar honganxue commented on June 15, 2024

image
2020-09-29 12:47:16.125 11246-11246/com.example.transferstation.activity E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.transferstation.activity, PID: 11246
java.lang.IllegalArgumentException: unexpected host: 120.24.62.145:8153/admin/login/token
at okhttp3.HttpUrl$Builder.host(HttpUrl.java:1035)
at com.example.transferstation.activity.LoginActivity.login(LoginActivity.java:89)
at com.example.transferstation.activity.LoginActivity$2.onClick(LoginActivity.java:77)
at android.view.View.performClick(View.java:6597)
at android.view.View.performClickInternal(View.java:6574)
at android.view.View.access$3100(View.java:778)
at android.view.View$PerformClick.run(View.java:25885)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:6669)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

from baseokhttpv3.

kongzue avatar kongzue commented on June 15, 2024

您好,您的创建方式有误。
请使用如下方式创建:

HttpUrl httpUrl = new HttpUrl.Builder()
        .scheme("http")
        .host("120.24.62.145")
        .port(8153)
        .addPathSegment("admin")
        .addPathSegment("login")
        .addPathSegment("token")
        .addQueryParameter("password","123456")
        .addQueryParameter("username","test")
        .build();

from baseokhttpv3.

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.