@@ -1606,6 +1606,8 @@ public void handlePost(final HttpExchange exchange) throws IOException {
16061606 private static class VerifyHandler extends AppPostHandler {
16071607 @ Override
16081608 public void handlePost (final HttpExchange exchange ) throws IOException , SQLiteException {
1609+ final boolean legacy = exchange .getRequestURI ().toString ().equals ("/verify" );
1610+
16091611 String authorization = null ;
16101612 try {
16111613 authorization = getRequestHeaderValue (exchange , "Authorization" );
@@ -1669,11 +1671,22 @@ public void handlePost(final HttpExchange exchange) throws IOException, SQLiteEx
16691671 return ;
16701672 }
16711673
1672- final byte [] result = (BaseEncoding .base64 ().encode (currentSubscribeKey ) + " " +
1673- verifyInterval ).getBytes ();
1674- exchange .sendResponseHeaders (200 , result .length );
1675- try (final OutputStream output = exchange .getResponseBody ()) {
1676- output .write (result );
1674+ if (legacy ) {
1675+ final byte [] result = (BaseEncoding .base64 ().encode (currentSubscribeKey ) + " " +
1676+ verifyInterval ).getBytes ();
1677+ exchange .sendResponseHeaders (200 , result .length );
1678+ try (final OutputStream output = exchange .getResponseBody ()) {
1679+ output .write (result );
1680+ }
1681+ } else {
1682+ final JsonObjectBuilder result = Json .createObjectBuilder ();
1683+ result .add ("verifyInterval" , verifyInterval );
1684+ exchange .getResponseHeaders ().set ("Content-Type" , "application/json" );
1685+ exchange .sendResponseHeaders (200 , 0 );
1686+ try (final OutputStream output = exchange .getResponseBody ();
1687+ final JsonWriter writer = Json .createWriter (output )) {
1688+ writer .write (result .build ());
1689+ }
16771690 }
16781691 }
16791692 }
0 commit comments