mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-02-21 09:51:50 +00:00
Fix java resful client after recent changes to mime types
This commit is contained in:
parent
988250a576
commit
dc0c0f86d8
@ -64,18 +64,20 @@ public abstract class AbstractJsonList<T, E extends Exception> {
|
||||
httpConnection = httpConnector.newServalDHttpConnection(url);
|
||||
httpConnection.connect();
|
||||
|
||||
if (!httpConnection.getContentType().equals("application/json"))
|
||||
throw new ServalDInterfaceException("unexpected HTTP Content-Type: " + httpConnection.getContentType());
|
||||
|
||||
json = new JSONTokeniser(
|
||||
(httpConnection.getResponseCode() >= 300) ?
|
||||
httpConnection.getErrorStream() : httpConnection.getInputStream());
|
||||
if ("application/json".equals(httpConnection.getContentType())){
|
||||
json = new JSONTokeniser(
|
||||
(httpConnection.getResponseCode() >= 300) ?
|
||||
httpConnection.getErrorStream() : httpConnection.getInputStream());
|
||||
}
|
||||
|
||||
if (httpConnection.getResponseCode()!=200){
|
||||
handleResponseError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (json == null)
|
||||
throw new ServalDInterfaceException("unexpected HTTP Content-Type: " + httpConnection.getContentType());
|
||||
|
||||
try{
|
||||
json.consume(JSONTokeniser.Token.START_OBJECT);
|
||||
// allow for extra optional fields
|
||||
|
@ -39,6 +39,6 @@ public class BundleId extends SigningKey {
|
||||
|
||||
@Override
|
||||
public String getMimeType() {
|
||||
return null;
|
||||
return "rhizome/bid";
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,6 @@ public class BundleSecret extends AbstractId {
|
||||
|
||||
@Override
|
||||
public String getMimeType() {
|
||||
return "rhizome/bundle-secret";
|
||||
return "rhizome/bundlesecret";
|
||||
}
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class PostHelper {
|
||||
}
|
||||
|
||||
public void writeField(String name, AbstractId value){
|
||||
writeHeading(name, null, value.getMimeType(), "hex");
|
||||
writeHeading(name, null, value.getMimeType()+"; format=hex", null);
|
||||
writer.print(value.toHex());
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class SubscriberId extends AbstractId {
|
||||
|
||||
@Override
|
||||
public String getMimeType() {
|
||||
return "serval-mesh/sid";
|
||||
return "serval/sid";
|
||||
}
|
||||
|
||||
public SubscriberId(String hex) throws InvalidHexException {
|
||||
|
@ -231,7 +231,7 @@ public class RhizomeCommon
|
||||
case NEW:
|
||||
return null;
|
||||
case SAME:
|
||||
if (!conn.getContentType().equals("rhizome-manifest/text"))
|
||||
if (!RhizomeManifest.MIME_TYPE.equals(conn.getContentType()))
|
||||
throw new ServalDInterfaceException("unexpected HTTP Content-Type: " + conn.getContentType());
|
||||
RhizomeManifest manifest = RhizomeManifest.fromTextFormat(status.input_stream);
|
||||
BundleExtra extra = bundleExtraFromHeaders(conn);
|
||||
@ -453,7 +453,7 @@ public class RhizomeCommon
|
||||
decodeHeaderBundleStatus(status, conn);
|
||||
checkBundleStatus(status);
|
||||
|
||||
if (!status.contentType.equals("rhizome-manifest/text"))
|
||||
if (!RhizomeManifest.MIME_TYPE.equals(status.contentType))
|
||||
throw new ServalDInterfaceException("unexpected HTTP Content-Type " + status.contentType + " from " + status.url);
|
||||
RhizomeManifest returned_manifest = RhizomeManifest.fromTextFormat(status.input_stream);
|
||||
BundleExtra extra = bundleExtraFromHeaders(conn);
|
||||
|
@ -43,7 +43,7 @@ import org.servalproject.servaldna.BundleKey;
|
||||
public class RhizomeManifest {
|
||||
|
||||
public final static int TEXT_FORMAT_MAX_SIZE = 8192;
|
||||
public static final String MIME_TYPE = "rhizome/manifest; format=\"text+binarysig\"";
|
||||
public static final String MIME_TYPE = "rhizome/manifest; format=text+binarysig";
|
||||
|
||||
// Core fields used for routing and expiry (cannot be null)
|
||||
public final BundleId id;
|
||||
|
Loading…
x
Reference in New Issue
Block a user