[PR #7826] [CLOSED] Use default transport to preserve proxy settings #17795

Closed
opened 2026-04-16 06:14:13 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/7826
Author: @Mazyod
Created: 11/25/2024
Status: Closed

Base: mainHead: patch-1


📝 Commits (1)

  • cf3b1f6 Use default transport to preserve proxy settings

📊 Changes

1 file changed (+9 additions, -3 deletions)

View changed files

📝 server/images.go (+9 -3)

📄 Description

Attempt to fix regression in 0.4.3 as per #7788

To test this change, I created a small program to verify that the change indeed respects the proxy settings:

package main

import (
	"fmt"
	"net/http"
	"os"
)

func BuggyClient() *http.Client {
	return &http.Client{
		Transport: &http.Transport{},
	}
}

func CorrectClient() *http.Client {
	transport := http.DefaultTransport.(*http.Transport).Clone()
	return &http.Client{
		Transport: transport,
	}
}

func main() {
	targetURL := "http://httpbin.org/get"

	fmt.Println("Testing with buggy client:")
	buggyResp, err := BuggyClient().Get(targetURL)
	if err != nil {
		fmt.Printf("Buggy client error: %v\n", err)
	} else {
		defer buggyResp.Body.Close()
		fmt.Printf("Buggy client status: %s\n", buggyResp.Status)
	}

	fmt.Println("\nTesting with correct client:")
	correctResp, err := CorrectClient().Get(targetURL)
	if err != nil {
		fmt.Printf("Correct client error: %v\n", err)
	} else {
		defer correctResp.Body.Close()
		fmt.Printf("Correct client status: %s\n", correctResp.Status)
	}

	fmt.Println("\nProxy settings:")
	fmt.Printf("HTTP_PROXY: %s\n", os.Getenv("HTTP_PROXY"))
}
# I run tinyproxy with DENY all requests for testing
% go run main.go
Testing with buggy client:
Buggy client status: 200 OK

Testing with correct client:
Correct client status: 403 Access denied

Proxy settings:
HTTP_PROXY: http://localhost:8888

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/7826 **Author:** [@Mazyod](https://github.com/Mazyod) **Created:** 11/25/2024 **Status:** ❌ Closed **Base:** `main` ← **Head:** `patch-1` --- ### 📝 Commits (1) - [`cf3b1f6`](https://github.com/ollama/ollama/commit/cf3b1f6bfdb33e6519c324dc8b5f066371a3a4b2) Use default transport to preserve proxy settings ### 📊 Changes **1 file changed** (+9 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `server/images.go` (+9 -3) </details> ### 📄 Description Attempt to fix regression in 0.4.3 as per #7788 To test this change, I created a small program to verify that the change indeed respects the proxy settings: ```go package main import ( "fmt" "net/http" "os" ) func BuggyClient() *http.Client { return &http.Client{ Transport: &http.Transport{}, } } func CorrectClient() *http.Client { transport := http.DefaultTransport.(*http.Transport).Clone() return &http.Client{ Transport: transport, } } func main() { targetURL := "http://httpbin.org/get" fmt.Println("Testing with buggy client:") buggyResp, err := BuggyClient().Get(targetURL) if err != nil { fmt.Printf("Buggy client error: %v\n", err) } else { defer buggyResp.Body.Close() fmt.Printf("Buggy client status: %s\n", buggyResp.Status) } fmt.Println("\nTesting with correct client:") correctResp, err := CorrectClient().Get(targetURL) if err != nil { fmt.Printf("Correct client error: %v\n", err) } else { defer correctResp.Body.Close() fmt.Printf("Correct client status: %s\n", correctResp.Status) } fmt.Println("\nProxy settings:") fmt.Printf("HTTP_PROXY: %s\n", os.Getenv("HTTP_PROXY")) } ``` ```bash # I run tinyproxy with DENY all requests for testing % go run main.go Testing with buggy client: Buggy client status: 200 OK Testing with correct client: Correct client status: 403 Access denied Proxy settings: HTTP_PROXY: http://localhost:8888 ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-16 06:14:13 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#17795