package org.xbib.io.webdav.client.methods;

import org.xbib.io.webdav.client.RebindInfo;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;

/**
 * Represents an HTTP REBIND request.
 *
 * @see <a href="http://webdav.org/specs/rfc5842.html#rfc.section.6">RFC 5842, Section 6</a>
 */
public class Rebind extends AbstractMethod {

    private final RebindInfo info;

    public Rebind(RebindInfo info) {
        this.info = info;
    }

    public String method() {
        return "REBIND";
    }

    @Override
    public HttpRequest.BodyPublisher bodyPublisher() {
        return publish(info);
    }

    public boolean succeeded(HttpResponse<?> response) {
        return response.statusCode() == 200 || response.statusCode() == 201;
    }
}