sirwellington / alchemy-http Goto Github PK
View Code? Open in Web Editor NEWTalk easily to REST Services in Java
License: Apache License 2.0
Talk easily to REST Services in Java
License: Apache License 2.0
The README examples for Java don't work anymore.
AlchemyHttp http = AlchemyHttp.newDefaultInstance();
newDefaultInstance() isn't available in AlchemyHttp.
While attempting to upload binary content (images, files, etc), the byte[] is treated as a pojo and it becomes corrupted on the server side.
Investigate whether we can provide the basic HTTP Client using just HttpUrlConnections
.
This will make the client even thinner and lighter.
This new effort will probably take place in a separate repository, since it's specifically for testing purposes. You don't want to clutter production code with test design and code
Alchemy HTTP is really picky about the Content Type it receives; it expects JSON or Plain Text, and will fail if it gets anything else. This is to prevent misrepresentation of Data.
Rather than making it strictly one way or the other, we should have the ability to add allowable content types, or to ignore the content type of the response entirely.
There isn't a central place containing HTTP Status codes, their meaning and codes.
There isn't a central place to get commonly used Content-Types
.
Create a class containing commonly used content types.
The HTTP Client crashes when it receives multiple header values for one header name,
for example
GitHub APIs often return
Vary: Accept, Authorization, Cookie, X-GitHub-OTP
This causes
java.lang.IllegalStateException: Duplicate key Accept, Authorization, Cookie, X-GitHub-OTP
at java.util.stream.Collectors.lambda$throwingMerger$115(Collectors.java:133) ~[na:1.8.0_66]
at java.util.HashMap.merge(HashMap.java:1245) ~[na:1.8.0_66]
at java.util.stream.Collectors.lambda$toMap$173(Collectors.java:1320) ~[na:1.8.0_66]
at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169) ~[na:1.8.0_66]
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948) ~[na:1.8.0_66]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481) ~[na:1.8.0_66]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471) ~[na:1.8.0_66]
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708) ~[na:1.8.0_66]
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:1.8.0_66]
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499) ~[na:1.8.0_66]
at tech.sirwellington.alchemy.http.HttpVerbImpl.extractHeadersFrom(HttpVerbImpl.java:187) ~[alchemy-http-1.1.1.jar:na]
at tech.sirwellington.alchemy.http.HttpVerbImpl.execute(HttpVerbImpl.java:128) ~[alchemy-http-1.1.1.jar:na]
at tech.sirwellington.alchemy.http.AlchemyMachineImpl.executeSync(AlchemyMachineImpl.java:141) ~[alchemy-http-1.1.1.jar:na]
at tech.sirwellington.alchemy.http.AlchemyHttpStateMachine.executeSync(AlchemyHttpStateMachine.java:71) [alchemy-http-1.1.1.jar:na]
at tech.sirwellington.alchemy.http.Step3Impl.at(Step3Impl.java:124) [alchemy-http-1.1.1.jar:na]
at tech.sirwellington.alchemy.http.AlchemyRequest$Step3.at(AlchemyRequest.java:168) [alchemy-http-1.1.1.jar:na]
at tech.aroma.banana.example.Main.callGithub(Main.java:101) [classes/:na]
at tech.aroma.banana.example.Main.main(Main.java:65) [classes/:na]
Exception in thread "main" tech.sirwellington.alchemy.http.exceptions.AlchemyHttpException: java.lang.IllegalStateException: Duplicate key Accept, Authorization, Cookie, X-GitHub-OTP
at tech.sirwellington.alchemy.http.AlchemyMachineImpl.executeSync(AlchemyMachineImpl.java:151)
at tech.sirwellington.alchemy.http.AlchemyHttpStateMachine.executeSync(AlchemyHttpStateMachine.java:71)
at tech.sirwellington.alchemy.http.Step3Impl.at(Step3Impl.java:124)
at tech.sirwellington.alchemy.http.AlchemyRequest$Step3.at(AlchemyRequest.java:168)
at tech.aroma.banana.example.Main.callGithub(Main.java:101)
at tech.aroma.banana.example.Main.main(Main.java:65)
Caused by: java.lang.IllegalStateException: Duplicate key Accept, Authorization, Cookie, X-GitHub-OTP
at java.util.stream.Collectors.lambda$throwingMerger$115(Collectors.java:133)
at java.util.HashMap.merge(HashMap.java:1245)
at java.util.stream.Collectors.lambda$toMap$173(Collectors.java:1320)
at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
at java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:948)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at tech.sirwellington.alchemy.http.HttpVerbImpl.extractHeadersFrom(HttpVerbImpl.java:187)
at tech.sirwellington.alchemy.http.HttpVerbImpl.execute(HttpVerbImpl.java:128)
at tech.sirwellington.alchemy.http.AlchemyMachineImpl.executeSync(AlchemyMachineImpl.java:141)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.