[jbosstools-issues] [JBoss JIRA] (JBIDE-13888) openshift-java-client: make sure useragent is sent

Andre Dietisheim (JIRA) jira-events at lists.jboss.org
Sun Mar 31 16:29:41 EDT 2013


    [ https://issues.jboss.org/browse/JBIDE-13888?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12764080#comment-12764080 ] 

Andre Dietisheim edited comment on JBIDE-13888 at 3/31/13 4:28 PM:
-------------------------------------------------------------------

In the openshift-java-client it currently looks like as if the useragent is not sent:

{code:title=RestServiceProperties}
	public String getUseragent(String id) {
		String version = getVersion();
		String useragentPattern = getUseragentPattern();
		if (!StringUtils.isEmpty(id)
				&& !StringUtils.isEmpty(version)
				&& !StringUtils.isEmpty(useragentPattern)) {
			String userAgent = MessageFormat.format(getUseragentPattern(), getVersion(), id);
		}
		return null;
	}
{code}

this method always returns *null*, thus the useragent should always be null.

It turned out that bill decoste unfortunately introduced this issue here: https://github.com/adietish/openshift-java-client/commit/b64d63fc50fc3911cb3db52dd9aa74e989bdea8c#L8L60

The http client will obviously not send the user agent since it would not set it if it's null:
{code:title=UrlConnectionHttpClient}
	private void setUserAgent(HttpURLConnection connection) {
		String userAgent = this.userAgent;
		if (!StringUtils.isEmpty(authKey)) {
			userAgent = USERAGENT_FOR_KEYAUTH;
		}
		
		if (userAgent != null){
			connection.setRequestProperty(PROPERTY_USER_AGENT, userAgent);
		}
	}

{code}
                
      was (Author: adietish):
    In the openshift-java-client it currently looks like as if the useragent is not sent:

{code:title=RestServiceProperties}
	public String getUseragent(String id) {
		String version = getVersion();
		String useragentPattern = getUseragentPattern();
		if (!StringUtils.isEmpty(id)
				&& !StringUtils.isEmpty(version)
				&& !StringUtils.isEmpty(useragentPattern)) {
			String userAgent = MessageFormat.format(getUseragentPattern(), getVersion(), id);
		}
		return null;
	}
{code}

this method always returns *null*, thus the useragent should always be null.

The http client will obviously not send the user agent since it would not set it if it's null:
{code:title=UrlConnectionHttpClient}
	private void setUserAgent(HttpURLConnection connection) {
		String userAgent = this.userAgent;
		if (!StringUtils.isEmpty(authKey)) {
			userAgent = USERAGENT_FOR_KEYAUTH;
		}
		
		if (userAgent != null){
			connection.setRequestProperty(PROPERTY_USER_AGENT, userAgent);
		}
	}

{code}
                  
> openshift-java-client: make sure useragent is sent
> --------------------------------------------------
>
>                 Key: JBIDE-13888
>                 URL: https://issues.jboss.org/browse/JBIDE-13888
>             Project: Tools (JBoss Tools)
>          Issue Type: Bug
>          Components: openshift
>    Affects Versions: 4.1.0.Alpha2
>            Reporter: Andre Dietisheim
>            Assignee: Andre Dietisheim
>             Fix For: 4.1.0.Alpha2
>
>


--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jbosstools-issues mailing list