Questions tagged [go-http]

This tag is for questions related to Go's HTTP package

Go's net/http package provides HTTP client and server implementations.

67 questions
2
votes
1 answer

Why can't Golang download certain webpages?

I want to download Fantasy Football Data to analyse in Go, but when I try to download from this api page then I get back an empty response, even though the code works for other websites, e.g. this api page Minimal reproduction, outputs an empty…
J Mead
  • 33
  • 4
1
vote
1 answer

How to fix TLS error on www.fedex.com when using uTls?

Can someone help me with fixing my TLS using uTls in go? Whenever I try a GET request for https://www.fedex.com/ I get: Get "https://www.fedex.com/": uTlsConn.Handshake() error: remote error: tls: internal error Here is my code: func…
jjboi8708
  • 13
  • 5
1
vote
1 answer

Is there a way to get all the open http connections on a host in go?

I have a go webserver. Is there a way where I can get all the open http connections on that host?
developer747
  • 13,032
  • 22
  • 78
  • 136
1
vote
1 answer

Remove trailing slash from urls - Go static server

I've set up a simple Go static file server with http.FileServer. If I have a directory structure like public > about > index.html, the server will correctly resolve /about to about > index.html, but it adds a trailing slash so the url becomes…
Luke Johnson
  • 103
  • 10
1
vote
1 answer

Sending file to Google drive API from golang code yields error: Unsupported content with type: image/jpeg

based on the Google Drive API docs the proper way of uploading a file is: curl -v -H 'Authorization: Bearer mytoken' -F 'metadata={"name": "test3.jpeg"};type=application/json' -F file=@jpeg_image.jpeg…
zakaria amine
  • 2,617
  • 16
  • 29
1
vote
1 answer

field state of web.Request struct not cloning properly in Golang

In trying to set up two different web.Request states for use in some test cases, one without any headers and one with, I run into issue: Setup I create fakeRequest,fakeRequestNoHeaders thus: // create fake request fakeRequest :=…
Mike Warren
  • 3,042
  • 4
  • 29
  • 76
0
votes
1 answer

Go Deep understanding of custom error handling in REST API

I am coming from the world of Node.js where I learn a lot from building web application using Express and there, there is a good way, I think, to handle when dealing with error and in case of unexpected error, there is a awesome way to catch it. So,…
Mael Elvis Fosso
  • 310
  • 4
  • 12
0
votes
2 answers

How to wrap a Go package with only a few modifications?

How can I write a Go package that wraps a library such that calls to overridden functions use my implementation, and non-overridden functions "fall through" to the library I am wrapping? In particular: I want my Go package to wrap net/http, except I…
jstrieb
  • 579
  • 1
  • 7
  • 20
0
votes
0 answers

Golang Two HTTP requests via one client

How to prepare two HTTP requests via one client on Go without problems with memory? I have the next code : func moduleView(url string) { var module Module httpClient := &http.Client{} moduleId, listHttpResponseCode :=…
0
votes
0 answers

On demand file generation with http.FileServer

I'm using net/http to build a thumbnail gallery server as a learning exercise. http.FileServer works fine for serving original versions of images. Now I'm exploring the possibility of using a similar technique for serving thumbnails. What I want is:…
Can
  • 313
  • 2
  • 7
0
votes
2 answers

How to use channel properly for concurrent POST API call and log the data in File

I am trying to design a HTTP client in Go that will be capable ofcConcurrent API calls to the web services and write some data in a textfile. func getTotalCalls() int { reader := bufio.NewReader(os.Stdin) ... return…
DataPsycho
  • 727
  • 6
  • 22
0
votes
0 answers

server panic when trying to implement qor dashboard with go-swagger generated api server

2021/02/12 17:17:56 Finish [GET] /admin Took 0.05ms 2021/02/12 17:17:56 http: panic serving 127.0.0.1:50746: runtime error: invalid memory address or nil pointer dereference goroutine 65 [running]: net/http.(*conn).serve.func1(0xc00076f040) …
0
votes
1 answer

in tests mux.Vars() returns nil instead of expected map

I have a Gorilla Mux router setup inside a function that returns *mux.Router, goes like this func MakeApp(services service.Service, pe PolicyEnforce) *mux.Router { app := mux.NewRouter() app.NotFoundHandler = &NotFound{} …
shackra
  • 364
  • 1
  • 12
  • 47
0
votes
0 answers

How to set up httpClient with pfx certificate?

I am creating an application which will communicate with other systems via rest APIs with one .pfx certificate. I have to write this application in Go. Any leads will be extremely helpful.
0
votes
2 answers

dial tcp i/o timeout with HTTP GET request

Running into some error, I must be overlooking something. How can I debug this? Dropping connections? I read the following: golang - Why net.DialTimeout get timeout half of the time? Go. Get error i/o timeout in server program golang get massive…
R.J.
  • 43
  • 1
  • 9