Dany Lavrov Dany Lavrov - 2 months ago 6x
HTTP Question

difference in GET request between HTTPS and HTTP

I have that allows me to connect to a server using SSL.
It works fine. However when i send a GET request to the server i get this response:

400 Bad Request Bad Request Your browser sent a request that this
server could not understand. Reason: You're speaking plain HTTP to an
SSL-enabled server port. Instead use the HTTPS scheme to access this
URL, please. Hint: https://cddis-caster.gsfc.nasa.gov/

Is there a difference between the GET request used for HTTP and a GET request used for HTTPS?
My GET request looks like this:
User-Agent: EXO-Client v1
Accept: */*
Connection: keep alive
Authorization: Basic YWhpbGxpZXI6NkdZVVRSc3A=

I send the request using the next code:

public class ntripClient implements Runnable{
private String nServer = "";
private String nMountpoint = "";
private String nUsername = "";
private String nPassword = "";
private int nPort = 0;
private boolean running = true, secure = false;
private boolean headread = false;

public ntripClient(String server, int port, String user, String pass, String mount, int type, String cType){
this.nServer = server;
this.nUsername = user;
this.nPassword = pass;
this.nMountpoint = mount;
this.nPort = port;
this.type = type;
if (cType.matches("Y")){
secure = true;

public void run() {
try {
Socket s = new Socket();
SocketAddress sockaddr = null;
// Creating Client Sockets
if (secure){
SSLSocketFactory sslsocketfactory = (SSLSocketFactory)SSLSocketFactory.getDefault();
SSLSocket sslSocket = (SSLSocket)sslsocketfactory.createSocket(nServer,nPort);
sockaddr = sslSocket.getRemoteSocketAddress();
} else {
sockaddr = new InetSocketAddress(nServer, nPort);
s.connect(sockaddr, 10 * 1000);
if (s.isConnected()) {
s.setSoTimeout(20 * 1000);
DataOutputStream out = new DataOutputStream (s.getOutputStream());
DataInputStream in = new DataInputStream (s.getInputStream());

// send a message to the server
String requestmsg = GETrequest();


while (running) {
// receive a response
int ln = in.available();
byte [] bytes = new byte [ln];
catch (UnknownHostException ex) {System.out.println(ex);}
catch (IOException ex) {System.out.println(ex);}
catch (InterruptedException ex) {System.out.println(ex);}

public class test {
public static void main(String[] args){
ntripClient NC = new ntripClient("cddis-caster.gsfc.nasa.gov", 443, "User", "Password", "", 3, "Y");

Thread T = new Thread(NC);


I am trying to connect to a secure ntrip server.
Any ideas? any help would be appreciated.


The GET request is the same for HTTP and HTTPS. But the difference is that you need to send it for HTTP on a plain socket (which you do) and for HTTPS on an SSL socket (which you don't). You attempt to do it by creating an SSLSocket sslSocket but then you use the plain TCP socket s for sending the request.