Skip to content

fix bug in gogs client #1736

Open
Open
@da1nerd

Description

@da1nerd

There is this bit of code

    /**
     * Performs a request against the api
     * @param partialUrl the api command
     * @param user the user authenticating this request. Requires token or username and pasword
     * @param postData if not null the request will POST the data otherwise it will be a GET request
     * @param requestMethod if null the request method will default to POST or GET
     * @return
     */
    private Response request(String partialUrl, User user, String postData, String requestMethod) {
        int responseCode = -1;
        String responseData = null;
        Exception exception = null;
        try {
            URL url = new URL(this.baseUrl + partialUrl.replaceAll("^/+", ""));
            HttpURLConnection conn;
            if(url.getProtocol() == "https") {
                conn = (HttpsURLConnection)url.openConnection();
            } else {
                conn = (HttpURLConnection)url.openConnection();
            }

That is incorrectly comparing strings. It should be if(url.getProtocol().equals("https")).

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions