Giter VIP home page Giter VIP logo

alchemy-http's People

Contributors

sirwellington avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

rajacsp

alchemy-http's Issues

Client crashes with multiple Header Values

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)

Common Content Types

There isn't a central place to get commonly used Content-Types.

Create a class containing commonly used content types.

README examples don't work

The README examples for Java don't work anymore.

AlchemyHttp http = AlchemyHttp.newDefaultInstance();

newDefaultInstance() isn't available in AlchemyHttp.

Design a testable AlchemyHttpClient

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

Add a parameter to determine content-type behavior

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.