3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-16 04:05:50 +00:00

Move BIP71 MIME types to PaymentProtocol class.

This commit is contained in:
Andreas Schildbach 2014-04-13 15:16:05 +02:00 committed by Mike Hearn
parent 40d60306fa
commit 81f62db0e9
2 changed files with 8 additions and 3 deletions

View File

@ -51,6 +51,11 @@ import com.google.protobuf.InvalidProtocolBufferException;
public class PaymentProtocol { public class PaymentProtocol {
// MIME types as defined in BIP71.
public static final String MIMETYPE_PAYMENTREQUEST = "application/bitcoin-paymentrequest";
public static final String MIMETYPE_PAYMENT = "application/bitcoin-payment";
public static final String MIMETYPE_PAYMENTACK = "application/bitcoin-paymentack";
/** /**
* Sign the provided payment request. * Sign the provided payment request.
* *

View File

@ -176,7 +176,7 @@ public class PaymentSession {
@Override @Override
public PaymentSession call() throws Exception { public PaymentSession call() throws Exception {
HttpURLConnection connection = (HttpURLConnection)uri.toURL().openConnection(); HttpURLConnection connection = (HttpURLConnection)uri.toURL().openConnection();
connection.setRequestProperty("Accept", "application/bitcoin-paymentrequest"); connection.setRequestProperty("Accept", PaymentProtocol.MIMETYPE_PAYMENTREQUEST);
connection.setUseCaches(false); connection.setUseCaches(false);
Protos.PaymentRequest paymentRequest = Protos.PaymentRequest.parseFrom(connection.getInputStream()); Protos.PaymentRequest paymentRequest = Protos.PaymentRequest.parseFrom(connection.getInputStream());
return new PaymentSession(paymentRequest, verifyPki, trustStoreLoader); return new PaymentSession(paymentRequest, verifyPki, trustStoreLoader);
@ -359,8 +359,8 @@ public class PaymentSession {
public Ack call() throws Exception { public Ack call() throws Exception {
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST"); connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/bitcoin-payment"); connection.setRequestProperty("Content-Type", PaymentProtocol.MIMETYPE_PAYMENT);
connection.setRequestProperty("Accept", "application/bitcoin-paymentack"); connection.setRequestProperty("Accept", PaymentProtocol.MIMETYPE_PAYMENTACK);
connection.setRequestProperty("Content-Length", Integer.toString(payment.getSerializedSize())); connection.setRequestProperty("Content-Length", Integer.toString(payment.getSerializedSize()));
connection.setUseCaches(false); connection.setUseCaches(false);
connection.setDoInput(true); connection.setDoInput(true);