Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .testdata/sample-file.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
THIS IS A SAMPLE FILE FOR TEST

https://github.com/imroc/req
https://github.com/bertold/req
58 changes: 29 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<p align="center"><img src="https://req.cool/images/req.png"></p>
<p align="center"><strong>Simple Go HTTP client with Black Magic</strong></p>
<p align="center">
<a href="https://github.com/imroc/req/actions/workflows/ci.yml?query=branch%3Amaster"><img src="https://github.com/imroc/req/actions/workflows/ci.yml/badge.svg" alt="Build Status"></a>
<a href="https://goreportcard.com/report/github.com/imroc/req/v3"><img src="https://goreportcard.com/badge/github.com/imroc/req/v3" alt="Go Report Card"></a>
<a href="https://pkg.go.dev/github.com/imroc/req/v3"><img src="https://pkg.go.dev/badge/github.com/imroc/req/v3.svg"></a>
<a href="LICENSE"><img src="https://img.shields.io/github/license/imroc/req.svg" alt="License"></a>
<a href="https://github.com/imroc/req/releases"><img src="https://img.shields.io/github/v/release/imroc/req?display_name=tag&sort=semver" alt="GitHub Releases"></a>
<a href="https://github.com/bertold/req/actions/workflows/ci.yml?query=branch%3Amaster"><img src="https://github.com/bertold/req/actions/workflows/ci.yml/badge.svg" alt="Build Status"></a>
<a href="https://goreportcard.com/report/github.com/bertold/req/v3"><img src="https://goreportcard.com/badge/github.com/bertold/req/v3" alt="Go Report Card"></a>
<a href="https://pkg.go.dev/github.com/bertold/req/v3"><img src="https://pkg.go.dev/badge/github.com/bertold/req/v3.svg"></a>
<a href="LICENSE"><img src="https://img.shields.io/github/license/bertold/req.svg" alt="License"></a>
<a href="https://github.com/bertold/req/releases"><img src="https://img.shields.io/github/v/release/bertold/req?display_name=tag&sort=semver" alt="GitHub Releases"></a>
<a href="https://github.com/avelino/awesome-go"><img src="https://awesome.re/mentioned-badge.svg" alt="Mentioned in Awesome Go"></a>
</p>
</p>
Expand Down Expand Up @@ -38,15 +38,15 @@ Full documentation is available on the official website: https://req.cool.
You first need [Go](https://go.dev/) installed (version 1.24+ is required), then you can use the below Go command to install req:

``` sh
go get github.com/imroc/req/v3
go get github.com/bertold/req/v3
```

**Import**

Import req to your code:

```go
import "github.com/imroc/req/v3"
import "github.com/bertold/req/v3"
```

**Basic Usage**
Expand All @@ -60,7 +60,7 @@ $ cat main.go
package main

import (
"github.com/imroc/req/v3"
"github.com/bertold/req/v3"
)

func main() {
Expand All @@ -79,7 +79,7 @@ $ go run main.go
:method: GET
:path: /uuid
:scheme: https
user-agent: req/v3 (https://github.com/imroc/req/v3)
user-agent: req/v3 (https://github.com/bertold/req/v3)
accept-encoding: gzip

:status: 200
Expand All @@ -97,7 +97,7 @@ access-control-allow-credentials: true
2022/05/19 10:05:09.340974 DEBUG [req] HTTP/1.1 GET https://httpbin.org/uuid
GET /uuid HTTP/1.1
Host: httpbin.org
User-Agent: req/v3 (https://github.com/imroc/req/v3)
User-Agent: req/v3 (https://github.com/bertold/req/v3)
Accept-Encoding: gzip

HTTP/1.1 200 OK
Expand Down Expand Up @@ -136,7 +136,7 @@ package main

import (
"fmt"
"github.com/imroc/req/v3"
"github.com/bertold/req/v3"
"log"
)

Expand Down Expand Up @@ -164,7 +164,7 @@ package main

import (
"fmt"
"github.com/imroc/req/v3"
"github.com/bertold/req/v3"
"log"
"time"
)
Expand All @@ -187,7 +187,7 @@ func main() {
var errMsg ErrorMessage
resp, err := client.R().
SetHeader("Accept", "application/vnd.github.v3+json"). // Chainable request settings.
SetPathParam("username", "imroc"). // Replace path variable in url.
SetPathParam("username", "bertold"). // Replace path variable in url.
SetSuccessResult(&userInfo). // Unmarshal response body into userInfo automatically if status code is between 200 and 299.
SetErrorResult(&errMsg). // Unmarshal response body into errMsg automatically if status code >= 400.
EnableDump(). // Enable dump at request level, only print dump content if there is an error or some unknown situation occurs to help troubleshoot.
Expand Down Expand Up @@ -220,7 +220,7 @@ func main() {
Normally it will output (SuccessState):

```txt
roc (https://imroc.cc)
roc (https://bertold.cc)
```

## <a name="More-Advanced-Get">More Advanced GET</a>
Expand All @@ -232,7 +232,7 @@ package main

import (
"fmt"
"github.com/imroc/req/v3"
"github.com/bertold/req/v3"
"log"
"time"
)
Expand Down Expand Up @@ -274,7 +274,7 @@ func main() {
var userInfo UserInfo
resp, err := client.R().
SetHeader("Accept", "application/vnd.github.v3+json"). // Chainable request settings
SetPathParam("username", "imroc").
SetPathParam("username", "bertold").
SetSuccessResult(&userInfo). // Unmarshal response body into userInfo automatically if status code is between 200 and 299.
Get("https://api.github.com/users/{username}")

Expand All @@ -296,7 +296,7 @@ package main

import (
"fmt"
"github.com/imroc/req/v3"
"github.com/bertold/req/v3"
"log"
)

Expand All @@ -314,7 +314,7 @@ func main() {
var result Result

resp, err := client.R().
SetBody(&Repo{Name: "req", Url: "https://github.com/imroc/req"}).
SetBody(&Repo{Name: "req", Url: "https://github.com/bertold/req"}).
SetSuccessResult(&result).
Post("https://httpbin.org/post")
if err != nil {
Expand All @@ -337,12 +337,12 @@ func main() {
:method: POST
:path: /post
:scheme: https
user-agent: req/v3 (https://github.com/imroc/req/v3)
user-agent: req/v3 (https://github.com/bertold/req/v3)
content-type: application/json; charset=utf-8
content-length: 55
accept-encoding: gzip

{"name":"req","website":"https://github.com/imroc/req"}
{"name":"req","website":"https://github.com/bertold/req"}

:status: 200
date: Thu, 19 May 2022 12:11:00 GMT
Expand All @@ -354,27 +354,27 @@ access-control-allow-credentials: true

{
"args": {},
"data": "{\"name\":\"req\",\"website\":\"https://github.com/imroc/req\"}",
"data": "{\"name\":\"req\",\"website\":\"https://github.com/bertold/req\"}",
"files": {},
"form": {},
"headers": {
"Accept-Encoding": "gzip",
"Content-Length": "55",
"Content-Type": "application/json; charset=utf-8",
"Host": "httpbin.org",
"User-Agent": "req/v3 (https://github.com/imroc/req/v3)",
"User-Agent": "req/v3 (https://github.com/bertold/req/v3)",
"X-Amzn-Trace-Id": "Root=1-628633d4-7559d633152b4307288ead2e"
},
"json": {
"name": "req",
"website": "https://github.com/imroc/req"
"website": "https://github.com/bertold/req"
},
"origin": "103.7.29.30",
"url": "https://httpbin.org/post"
}

++++++++++++++++++++++++++++++++++++++++++++++++
data: {"name":"req","url":"https://github.com/imroc/req"}
data: {"name":"req","url":"https://github.com/bertold/req"}
++++++++++++++++++++++++++++++++++++++++++++++++
```

Expand All @@ -387,7 +387,7 @@ package main

import (
"fmt"
"github.com/imroc/req/v3"
"github.com/bertold/req/v3"
)

type APIResponse struct {
Expand Down Expand Up @@ -425,7 +425,7 @@ Here is an example of building GitHub's SDK with req, using two styles (`GetUser
import (
"context"
"fmt"
"github.com/imroc/req/v3"
"github.com/bertold/req/v3"
)

type ErrorMessage struct {
Expand Down Expand Up @@ -502,14 +502,14 @@ func (c *GithubClient) GetUserProfile_Style2(ctx context.Context, username strin

## Contributing

If you have a bug report or feature request, you can [open an issue](https://github.com/imroc/req/issues/new), and [pull requests](https://github.com/imroc/req/pulls) are also welcome.
If you have a bug report or feature request, you can [open an issue](https://github.com/bertold/req/issues/new), and [pull requests](https://github.com/bertold/req/pulls) are also welcome.

## Contact

If you have questions, feel free to reach out to us in the following ways:

* [Github Discussion](https://github.com/imroc/req/discussions)
* [Slack](https://imroc-req.slack.com/archives/C03UFPGSNC8) | [Join](https://slack.req.cool/)
* [Github Discussion](https://github.com/bertold/req/discussions)
* [Slack](https://bertold-req.slack.com/archives/C03UFPGSNC8) | [Join](https://slack.req.cool/)

## Sponsors

Expand Down
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ req version >= `v3.43.x`

## Reporting a Vulnerability

Email: roc@imroc.cc
Email: roc@bertold.cc
8 changes: 4 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import (
utls "github.com/refraction-networking/utls"
"golang.org/x/net/publicsuffix"

"github.com/imroc/req/v3/http2"
"github.com/imroc/req/v3/internal/header"
"github.com/imroc/req/v3/internal/util"
"github.com/bertold/req/v3/http2"
"github.com/bertold/req/v3/internal/header"
"github.com/bertold/req/v3/internal/util"

"github.com/google/go-querystring/query"
)
Expand Down Expand Up @@ -557,7 +557,7 @@ func (c *Client) DevMode() *Client {
}

// SetScheme set the default scheme for client, will be used when
// there is no scheme in the request URL (e.g. "github.com/imroc/req").
// there is no scheme in the request URL (e.g. "github.com/bertold/req").
func (c *Client) SetScheme(scheme string) *Client {
if !util.IsStringEmpty(scheme) {
c.scheme = strings.TrimSpace(scheme)
Expand Down
2 changes: 1 addition & 1 deletion client_impersonate.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strconv"
"strings"

"github.com/imroc/req/v3/http2"
"github.com/bertold/req/v3/http2"
utls "github.com/refraction-networking/utls"
)

Expand Down
8 changes: 4 additions & 4 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import (
"testing"
"time"

"github.com/imroc/req/v3/internal/header"
"github.com/imroc/req/v3/internal/tests"
"github.com/bertold/req/v3/internal/header"
"github.com/bertold/req/v3/internal/tests"
"golang.org/x/net/publicsuffix"
)

Expand Down Expand Up @@ -213,7 +213,7 @@ func TestSetCommonHeadersNonCanonical(t *testing.T) {
}

func TestSetCommonBasicAuth(t *testing.T) {
c := tc().SetCommonBasicAuth("imroc", "123456")
c := tc().SetCommonBasicAuth("bertold", "123456")
tests.AssertEqual(t, "Basic aW1yb2M6MTIzNDU2", c.Headers.Get("Authorization"))
}

Expand Down Expand Up @@ -678,7 +678,7 @@ func TestSetResponseBodyTransformer(t *testing.T) {
resp, err := c.R().SetSuccessResult(user).Get("/urlencode")
assertSuccess(t, resp, err)
tests.AssertEqual(t, user.Username, "我是roc")
tests.AssertEqual(t, user.Email, "roc@imroc.cc")
tests.AssertEqual(t, user.Email, "roc@bertold.cc")
}

func TestSetResultStateCheckFunc(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion client_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"net/url"
"time"

"github.com/imroc/req/v3/http2"
"github.com/bertold/req/v3/http2"
utls "github.com/refraction-networking/utls"
)

Expand Down
2 changes: 1 addition & 1 deletion decode.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package req

import (
"github.com/imroc/req/v3/internal/charsets"
"github.com/bertold/req/v3/internal/charsets"
"io"
"strings"
)
Expand Down
2 changes: 1 addition & 1 deletion decode_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package req

import (
"github.com/imroc/req/v3/internal/tests"
"github.com/bertold/req/v3/internal/tests"
"testing"
)

Expand Down
2 changes: 1 addition & 1 deletion digest.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"

"github.com/icholy/digest"
"github.com/imroc/req/v3/internal/header"
"github.com/bertold/req/v3/internal/header"
)

// cchal is a cached challenge and the number of times it's been used.
Expand Down
2 changes: 1 addition & 1 deletion dump.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package req

import (
"github.com/imroc/req/v3/internal/dump"
"github.com/bertold/req/v3/internal/dump"
"io"
"os"
)
Expand Down
2 changes: 1 addition & 1 deletion examples/find-popular-repo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ go run .
Change the global `username` variable to your own github username:

```go
var username = "imroc"
var username = "bertold"
```
4 changes: 2 additions & 2 deletions examples/find-popular-repo/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ go 1.24

toolchain go1.24.4

replace github.com/imroc/req/v3 => ../../
replace github.com/bertold/req/v3 => ../../

require github.com/imroc/req/v3 v3.0.0
require github.com/bertold/req/v3 v3.0.0

require (
github.com/andybalholm/brotli v1.2.0 // indirect
Expand Down
4 changes: 2 additions & 2 deletions examples/find-popular-repo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"fmt"
"strconv"

"github.com/imroc/req/v3"
"github.com/bertold/req/v3"
)

// Change the name if you want
var username = "imroc"
var username = "bertold"

func main() {
repo, star, err := findTheMostPopularRepo(username)
Expand Down
6 changes: 3 additions & 3 deletions examples/opentelemetry-jaeger-tracing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ go run .
Please give a github username:
```

Input a github username, e.g. `imroc`:
Input a github username, e.g. `bertold`:

```bash
$ go run .
Please give a github username: imroc
The moust popular repo of roc (https://imroc.cc) is req, which have 2500 stars
Please give a github username: bertold
The moust popular repo of roc (https://bertold.cc) is req, which have 2500 stars
```

Then enter the Jaeger UI with browser (`http://127.0.0.1:16686/`), checkout the tracing details.
Expand Down
2 changes: 1 addition & 1 deletion examples/opentelemetry-jaeger-tracing/github/github.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package github
import (
"context"
"fmt"
"github.com/imroc/req/v3"
"github.com/bertold/req/v3"
"go.opentelemetry.io/otel/attribute"
"go.opentelemetry.io/otel/codes"
"go.opentelemetry.io/otel/trace"
Expand Down
Loading
Loading