Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

setUri() invalidates relative URI when setting default ports #36

Closed

Description

@antiphp

Hi,

when setting a relative URI /example the Zend\Http\Client::setUri() method adds a default port and so invalidates the URI resulting in isValidRelative() returning FALSE instead of TRUE.

<?php
require './vendor/autoload.php';
$relativeUri = '/example';
$client = new Zend\Http\Client($relativeUri);
$uri = new Zend\Uri\Http($relativeUri);
var_dump($client->getUri()->isValidRelative(), $uri->isValidRelative());

Expected output

boolean(true)
boolean(true)

Actual output

boolean(false)
boolean(true)

I don't know how to build a patch, but line 323 of Client.php should be
if (! $this->getUri()->getPort() && $this->getUri()->isAbsolute()) {
instead of
if (! $this->getUri()->getPort()) {

Cheers

Activity

  1. added a commit that references this issue on May 6, 2018
    47fb199
  2. samsonasik commented on May 6, 2018

    @samsonasik
    Contributor

    @antiphp I've created PR #149 for it

  3. added a commit that references this issue on Aug 13, 2018
    3a8fa0b
  4. added 2 commits that reference this issue on Jan 8, 2019
    75969b6
    b98e979
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions