Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issues in webservice quickstart #54

Merged
merged 3 commits into from
May 20, 2024
Merged

Fix Issues in webservice quickstart #54

merged 3 commits into from
May 20, 2024

Conversation

damjad
Copy link
Contributor

@damjad damjad commented May 16, 2024

The zio-quickstart-restful-webservice does not work as expected as mentioned in the documentation. https://zio.dev/guides/quickstarts/restful-webservice/

Issue 1:

For Download Routes, it's not returning the correctly formed output. Apparently, the fromStream method uses a binary encoder, and fromStreamChunked does not.

Expected output:

curl -i http://localhost:8080/download
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=file.txt
transfer-encoding: chunked

line number 1
1, 2, 3, 4, 5
line number 3
end of file

Actual Output

curl -i http://localhost:8080/download
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Content-Disposition: attachment; filename=file.txt
transfer-encoding: chunked

1081051101013211011710998101114324910494432504432514432524432531010810511010132110117109981011143251101011101003211110232102105108101

Issue 2:

For Greetings Routes, the logic of the routes is not correct. The /greet route does not return the correct response.

Expected Output

user@host ~> curl -i localhost:8080/greet
HTTP/1.1 200 OK
content-type: text/plain
content-length: 12

Hello World!

Actual Output

user@host ~> curl -i localhost:8080/greet
HTTP/1.1 400 Bad Request
warning: 199 ZIO HTTP "The name query parameter is missing!"
date: Thu, 16 May 2024 13:19:17 GMT
content-length: 0

Issue 3:

Moreover, the logic for handling multiple names is also incorrect.

Expected Output

user@host ~> curl -i localhost:8080/greet
HTTP/1.1 200 OK
content-type: text/plain
content-length: 12

Hello Danish and Amjad!

Actual Output

user@host ~> curl -i "localhost:8080/greet?name=Danish&name=Amjad"
HTTP/1.1 200 OK
content-type: text/plain
date: Thu, 16 May 2024 13:23:24 GMT
content-length: 71

Hello Chunk(D and a and n and i and s and h,A and m and j and a and d)!

@CLAassistant
Copy link

CLAassistant commented May 16, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@khajavi khajavi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

@khajavi khajavi merged commit f38e4eb into zio:master May 20, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants