Comments (22)
@yegor256/z please, pay attention to this issue
from cactoos-http.
@g4s8/z this project will fix the problem faster if you donate a few dollars to it; just click here and pay via Stripe, it's very fast, convenient and appreciated; thanks a lot!
from cactoos-http.
@llorllale I was actually looking how to do a request and it turns out I need to construct the http request using strings. Having something like here would make it much easier.
from cactoos-http.
@g4s8 I think we should recommend our users to use those request building objects from Takes Framework. Reimplementing them here would be silly, I think.
from cactoos-http.
@llorllale so this could be about extending the documentation (README.md) with example usage (replacing the JoinedText example with something less bare bones and more abstract).
from cactoos-http.
@yegor256 you meant that cactoos-http
should depends on takes
? I think it's not good, because it can be used not in web apps only or with other web-frameworks.
from cactoos-http.
@g4s8 no, it shouldn't depend on Takes. But, as @krzyk suggested, we should say in our README that: "if you need a more powerful instrument to build those HTTP requests, use Takes Framework, for example: ..."
from cactoos-http.
@yegor256 why isn't Takes included in the list of competitors?
from cactoos-http.
@llorllale because it doesn't know how to make HTTP requests. It can only build them in text form.
from cactoos-http.
@yegor256 I think you meant jcabi-http
when you said:
I think we should recommend our users to use those request building objects from Takes Framework. Reimplementing them here would be silly, I think.
But I believe the design of jcabi-http
is exactly what we're trying to avoid in cactoos-http
.
from cactoos-http.
@llorllale I meant Takes, not jcabi-http
from cactoos-http.
@g4s8 @yegor256 @krzyk it would sound really weird for cactoos-http
to direct users to another lib/framework just to fulfill this simple requirement (build http requests).
from cactoos-http.
we should recommend our users to use those request building objects from Takes Framework. Reimplementing them here would be silly,
I think then Takes
should depend on cactoos-http
from cactoos-http.
@llorllale well, not a bad idea, but will require a lot of refactoring and class moving...
from cactoos-http.
@yegor256 Takes
has the option of just continuing doing their own thing.
from cactoos-http.
@g4s8 why did you leave out Wire
in your proposal?
from cactoos-http.
@yegor256 @g4s8 tell me what you think:
new HtResponse(
new HtWire("host", port),
new RqHeaders(
new IterableOf<>(
"Host: host:port",
"Accept: */*"
),
new RqBase(
"GET", "/some/resource",
)
)
)
All requests would still be of type org.cactoos.Input
.
With these decorators, we will basically be splicing and joining several Input
or InputStream
into a single one.
What we would need:
- An equivalent for java's
SequenceInputStream
(org.cactoos.io.JoinedInput
that implementsInput
) SkipInput
(I'm tempted to rename to something else)- The opposite of
SkipInput
Thoughts
Insisting on keeping the Input
abstraction on requests sure makes implementing decorators more difficult.
from cactoos-http.
@llorllale I like the code snippet above, but I didn't understand the text beneath. We already have everything that we need for this code. What else is needed and what is your question?
from cactoos-http.
In my example above, we have two requests - RqBase
and RqHeaders
- and both are of type Input
.
A Wire
accepts only one Input
in its method: Input send(Input request);
.
Therefore we need to join all those requests/inputs into a single one and send it via the wire.
My question was if you guys accept this solution?
from cactoos-http.
@llorllale I didn't understand this:
In my example above, we have two requests - RqBase and RqHeaders - and both are of type Input.
RqBase
(from Takes) is of time Request
. I'm lost.
from cactoos-http.
@yegor256 the requirement is for providing "simple requests", not necessarily copy request objects from Takes.
Here is my example again with the Htr
prefix to avoid confusion:
new HtResponse(
new HtWire("host", port),
new HtrHeaders(
new IterableOf<>(
"Host: host:port",
"Accept: */*"
),
new HtrBase(
"GET", "/some/resource",
)
)
)
This Htr
prefix is only valid for the purposes of this example, as I have yet to come up with a better prefix. (I think there would be too many naming conflicts if we use Ht
for these)
from cactoos-http.
@g4s8 @llorllale @yegor256 for the record, there are such simple request objects already emerging in the test code base of cactoos-http, see #79. Just noting that here so that they are merged with whatever solution is found in this issue :)
from cactoos-http.
Related Issues (20)
- GET Request example not work in Kotlin
- Dependency Dashboard
- EO violation in Wire? HOT 4
- Update jcabi-parent to 0.49.4 (solves xcop issue) HOT 4
- Update cactoos to 0.39 HOT 11
- HtKeepAliveResponse.java:58-66: Replace the HtWire by... HOT 25
- BoundedByteBuffer.java:79-81: Figure out a more elegant... HOT 11
- HtWireTest.java:103-106: HtWire should not close the... HOT 17
- HtAutoClosedResponseTest.java:40-45: Introduce... HOT 14
- HtResponse.java:37-40: We need decorators for HtResponse... HOT 10
- Update maven-compiler-plugin and fix bug on it to allow incremental compilation HOT 2
- 'Get' class is in wrong package HOT 16
- Target architecture and main responsibilities HOT 2
- HtTimedWireTest.java:79-81: With #78 solved, HtWire... HOT 22
- Travis build fails installing oraclejdk8 HOT 9
- Upgrade openjdk HOT 13
- Bump copyright dates to 2020 HOT 10
- Change project ARC HOT 4
- BlockingSocketServer.java:45-52: Rework the... HOT 14
- BlockingSocketServer.java:98-100: Update cactoos to at... HOT 25
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cactoos-http.