• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

openmrs / openmrs-module-webservices.rest / 13932835190

18 Mar 2025 08:26PM UTC coverage: 47.667% (-0.01%) from 47.677%
13932835190

push

github

dkayiwa
RESTWS-965 generate correct protocol

0 of 4 new or added lines in 1 file covered. (0.0%)

6764 of 14190 relevant lines covered (47.67%)

0.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

7.69
/omod-common/src/main/java/org/openmrs/module/webservices/rest/web/v1_0/controller/BaseUriSetup.java
1
/**
2
 * This Source Code Form is subject to the terms of the Mozilla Public License,
3
 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
4
 * obtain one at http://mozilla.org/MPL/2.0/. OpenMRS is also distributed under
5
 * the terms of the Healthcare Disclaimer located at http://openmrs.org/license.
6
 *
7
 * Copyright (C) OpenMRS Inc. OpenMRS is a registered trademark and the OpenMRS
8
 * graphic logo is a trademark of OpenMRS Inc.
9
 */
10
package org.openmrs.module.webservices.rest.web.v1_0.controller;
11

12
import javax.servlet.http.HttpServletRequest;
13

14
import org.apache.commons.lang.StringUtils;
15
import org.openmrs.module.webservices.rest.web.RestConstants;
16
import org.springframework.stereotype.Component;
17

18
@Component
19
public class BaseUriSetup {
1✔
20
        
21
        public synchronized void setup(HttpServletRequest request) {
22
                if (!RestConstants.URI_PREFIX.startsWith("http://") && !RestConstants.URI_PREFIX.startsWith("https://")) {
×
23
                        StringBuilder uri = new StringBuilder();
×
24
                        
NEW
25
                        String scheme = request.getScheme();
×
NEW
26
                        if (StringUtils.isNotBlank(request.getHeader("X-Forwarded-Proto"))) {
×
NEW
27
                                scheme = request.getHeader("X-Forwarded-Proto");
×
28
                        }
NEW
29
                        uri.append(scheme).append("://").append(request.getServerName());
×
30
                        if (request.getServerPort() != 80) {
×
31
                                uri.append(":").append(request.getServerPort());
×
32
                        }
33
                        if (!StringUtils.isBlank(request.getContextPath())) {
×
34
                                uri.append(request.getContextPath());
×
35
                        }
36
                        
37
                        RestConstants.URI_PREFIX = uri.toString() + RestConstants.URI_PREFIX;
×
38
                }
39
        }
×
40
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc