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

Set correct content type and send once #1965

Merged
merged 4 commits into from
Jun 2, 2024

Conversation

matt0x6F
Copy link
Contributor

What is the problem I am trying to address?

Content types are being sent more than once and are often incorrectly set. See #1930

How is the fix applied?

Set the content type directly on handlers and remove content type middleware

What GitHub issue(s) does this PR fix or close?

Fixes #1930
Fixes #1958

@matt0x6F matt0x6F self-assigned this May 23, 2024
@matt0x6F matt0x6F requested a review from a team as a code owner May 23, 2024 02:01
@matt0x6F
Copy link
Contributor Author

You can test this locally by running athens from the repo. Then use curl:

❯ curl -v localhost:3000
*   Trying 127.0.0.1:3000...
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET / HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/7.81.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Content-Type: text/html
< Date: Thu, 23 May 2024 02:11:51 GMT
< Transfer-Encoding: chunked
< 
<!DOCTYPE html>
<html>
<head>
        <title>Athens</title>
        <style>
                body {
                        font-family: Arial, sans-serif;
                        margin: 20px;
                }

                pre {
                                background-color: #f4f4f4;
                                padding: 5px;
                                border-radius: 5px;
                                width: fit-content;
                                padding: 10px;
                }


                code {
                        background-color: #f4f4f4;
                        padding: 5px;
                        border-radius: 5px;
                }

        </style>
</head>
<body>

        <h1>Welcome to Athens</h1>

        <h2>Configuring your client</h2>
        <pre>GOPROXY=http://localhost:3000,direct</pre>


        <h2>How to use the Athens API</h2>
        <p>Use the <a href="/catalog">catalog</a> endpoint to get a list of all modules in the proxy</p>

        <h3>List of versions</h3>
        <p>This endpoint returns a list of versions that Athens knows about for <code>acidburn/htp</code>:</p>
        <pre>GET http://localhost:3000/github.com/acidburn/htp/@v/list</pre>

        <h3>Version info</h3>
        <p>This endpoint returns information about a specific version of a module:</p>
        <pre>GET http://localhost:3000/github.com/acidburn/htp/@v/v1.0.0.info</pre>
        <p>This returns JSON with information about v1.0.0. It looks like this:
        <pre>{
        "Name": "v1.0.0",
        "Short": "v1.0.0",
        "Version": "v1.0.0",
        "Time": "1972-07-18T12:34:56Z"
}</pre>

        <h3>go.mod file</h3>
        <p>This endpoint returns the go.mod file for a specific version of a module:</p>
        <pre>GET http://localhost:3000/github.com/acidburn/htp/@v/v1.0.0.mod</pre>
        <p>This returns the go.mod file for version v1.0.0. If http://localhost:3000/github.com/acidburn/htp version v1.0.0 has no dependencies, the response body would look like this:</p>
        <pre>module github.com/acidburn/htp</pre>

        <h3>Module sources</h3>
        <pre>GET http://localhost:3000/github.com/acidburn/htp/@v/v1.0.0.zip</pre>
        <p>This is what it sounds like — it sends back a zip file with the source code for the module in version v1.0.0.</p>

        <h3>Latest</h3>
        <pre>GET http://localhost:3000/github.com/acidburn/htp/@latest</pre>
        <p>This endpoint returns the latest version of the module. If the version does not exist it should retrieve the hash of latest commit.</p>

</body>
</html>
* Connection #0 to host localhost left intact

@matt0x6F matt0x6F enabled auto-merge (squash) June 2, 2024 19:20
@matt0x6F matt0x6F merged commit bde4952 into gomods:main Jun 2, 2024
11 checks passed
@matt0x6F matt0x6F added this to the 0.14.1 milestone Jun 2, 2024
matt0x6F pushed a commit to gomods/athens-charts that referenced this pull request Jun 3, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [gomods/athens](https://togithub.com/gomods/athens) | patch |
`v0.14.0` -> `v0.14.1` |

---

### Release Notes

<details>
<summary>gomods/athens (gomods/athens)</summary>

### [`v0.14.1`](https://togithub.com/gomods/athens/releases/tag/v0.14.1)

[Compare
Source](https://togithub.com/gomods/athens/compare/v0.14.0...v0.14.1)

#### What's Changed

- CI dependency updates in
[gomods/athens#1962
- Fix for AWS default credentials by
[@&#8203;yongzhang](https://togithub.com/yongzhang) in
[gomods/athens#1963
- Fix for E2E test runs by
[@&#8203;joeymhills](https://togithub.com/joeymhills) in
[gomods/athens#1966
- Feature gcp/saver: Only return errors.KindAlreadyExists if all three
exist by [@&#8203;dwbuiten](https://togithub.com/dwbuiten) in
[gomods/athens#1957
- Fix to set correct content type and send only once by
[@&#8203;matt0x6F](https://togithub.com/matt0x6F) in
[gomods/athens#1965

#### New Contributors

- [@&#8203;yongzhang](https://togithub.com/yongzhang) made their first
contribution in
[gomods/athens#1963
- [@&#8203;joeymhills](https://togithub.com/joeymhills) made their first
contribution in
[gomods/athens#1966
- [@&#8203;dwbuiten](https://togithub.com/dwbuiten) made their first
contribution in
[gomods/athens#1957

**Full Changelog**:
gomods/athens@v0.14.0...v0.14.1

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/gomods/athens-charts).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zNzcuOCIsInVwZGF0ZWRJblZlciI6IjM3LjM3Ny44IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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.

Introduction pages are broken Duplicate HTTP Content-Type header
2 participants